Chiamiamo questa tabella terms_relation
:selezionando le righe con id da un altro tavolo
+---------+----------+-------------+------------+------------+--+
| term_id | taxonomy | description | created_at | updated_at | |
+---------+----------+-------------+------------+------------+--+
| 1 | categ | non | 3434343434 | 34343433 | |
| 2 | categ | non | 3434343434 | 3434343434 | |
| 3 | tag | non | 3434343434 | 3434343434 | |
| 4 | tag | non | 3434343434 | 3434343434 | |
+---------+----------+-------------+------------+------------+--+
e questo è tavolo terms
:
+----+-------------+-------------+
| id | name | slug |
+----+-------------+-------------+
| 1 | hello | hello |
| 2 | how are you | how-are-you |
| 3 | tutorial | tutorial |
| 4 | the end | the-end |
+----+-------------+-------------+
Come faccio a selezionare tutte le righe nella tabella terms
e tavolo terms_relation
dove è la tassonomia nella tabella terms_relation
è categ
? Avrò bisogno di due query per questo o potrei usare una dichiarazione join
?
Ulteriori informazioni [SQL unisce] (http://www.codinghorror.com/blog/2007/10/a-visual -explanation-di-sql-joins.html). – eggyal
Sì, scopri i join SQL. Scopri http://sqlzoo.net/ e http://sqlfiddle.com/ –