I want to select some rows from my database from multiple tables
First table:
Table name: ctud
--------------------------------
id + user_id + dep_id
1 1 1
2 2 1
3 3 2
4 4 3
Second table:
Table name: cdot
-------------------------------
id + username + name
1 Hello Emre
2 Merhaba Emma
3 Aloha Micheal
4 Yup Test
I want to take data from both tables and for this, I am using this code:
select *
FROM ctud,cdot
where ctud.user_id = cdot.username
and ctud.user_id = 1;
but I get a blank screen.. What could be the reason for this?
ctud.user_idis the user's id, a number,cdot.usernameis a string, the user's name. You cannot join based on this. You need to use another table that would have bothuser_idandusernameand use that table also in your SQL.