Sql – Why doesn’t this SQL statement work

inner-joinsql

SELECT * FROM table1, table2
WHERE table1.user_id = table2.id
AND table1.content = news
AND table1.content_id = 1

that wont work. cant u have two "AND" in a sql statement??

//Tomek

Best Solution

you probably want to quote 'news' as a string... You also probably want to use an inner join instead (much more efficient)

SELECT * FROM table1
INNER JOIN table2 ON table1.user_id = table2.id 
WHERE table1.content = 'news' 
AND table1.content_id = 1