user3387719 user3387719 - 2 months ago 6
MySQL Question

MySqli - how can i SELECT ALL WHERE AND WHERE?

How can I get data from a table like the following:

SELECT Category,Icon_class,uri FROM
`menu_links`
JOIN
users
ON users.role_id = 1 WHERE Category ='employees' AND 'scoreboard'


I want to get certain rows only, and not the whole table. Mysql returns a syntax error.

Thanks!

Answer

Use this:

WHERE Category IN ('employees', 'scoreboard')

This assumes that you want records having a category of either employee or scoreboard. If you want something else, then let us know.