I have two tables in my mysql database.
table1: shoutbox
table2: users
My tables look like this
TABLE SHOUTBOX (id, name, title, user_id)
TABLE USERS (id, name, profile_image)
What i would like to do is display everything from table SHOUTBOX but
condition must be where profile_image = ‘2’ in USERS table So i’ve
tried this:
SELECT shoutbox.id, shoutbox.name, shoutbox.title, shoutbox.user_id, user.profile_image
FROM shoutbox, users
WHERE users.profile_image = '2'
and i’m getting very wrong results.
So i’m total newbie at this so please help out =)
you are getting the cartesian product from two tables because you lack the very important condition that links both tables. Add this condition on the
WHEREclause.but i urged you to use
SQL-92syntax