-3

i have problem with my project for my office

my table

tbl_phonebook
number     name
0814432     ahmad

tbl_inbox
SenderNumb     text
0814432          coba coba
0942042          sekalian

how to display data from the table inbox if the same number in the inbox with the number in the phonebook table displays the name and number in the inbox if there are no / not the same as the number in phonebook table shows the number of the original sender

tq before

Taufiq
  • 1
  • 2
  • 3
    Welcome to Stack Overflow! StackOverflow is not the proper place for this question. We do not write your code for you. You need to do your own coding and if you aren't sure why something is not working as expected, post the code with an explanation of what you were expecting it to do, and what it is actually doing including all error messages. See [about StackOverflow](http://stackoverflow.com/about). – John Conde Feb 15 '13 at 02:27

1 Answers1

0

I'm not completely sure I understand your problem. I think you want to use LEFT JOIN to see if the record exists in the phonebook table.

And perhaps use IFNULL to show the name or the sendernumb:

SELECT i.sendernumb,
    IFNULL(p.name,i.sendernumb) name,
    i.text text
FROM tbl_inbox i
    LEFT JOIN tbl_phonebook p ON i.SenderNumb = p.number
sgeddes
  • 62,311
  • 6
  • 61
  • 83
  • sorry if my question dificult to understain. yeah im try to use LEFT JOIN but only one data ( sendernum/name) show. and im newbie in mysql, by the way thanks for ur answer its help my to solve my problem im test and it works , once again thanks – Taufiq Feb 15 '13 at 04:51