简体   繁体   中英

Mysql inner joins where value in another table

This is probably a very simple solution but i cannot get my head around the syntax.

I have my first table:

ratings

id
name
status

I then have another table

sectors

id
ratingid
name

So my basic query is SELECT * FROM ratings but what I need to do is select all records from ratings WHERE I then look at the sectors table WHERE the sectorid is passed from $_GET and only show records where the sectorid matches the $_GET

Does that make sense? Any help very appreciated..

 SELECT * FROM sectors INNER JOIN ratings
 ON sectors.rating_id = ratings.id
 WHERE sectors.id = $_GET['yoursectorid'];

I think this is what you're looking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM