Vamos a llamar a esta tabla terms_relation
:seleccionar filas con el ID de otra tabla
+---------+----------+-------------+------------+------------+--+
| 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 | |
+---------+----------+-------------+------------+------------+--+
Y esta es la tabla terms
:
+----+-------------+-------------+
| id | name | slug |
+----+-------------+-------------+
| 1 | hello | hello |
| 2 | how are you | how-are-you |
| 3 | tutorial | tutorial |
| 4 | the end | the-end |
+----+-------------+-------------+
¿Cómo seleccionar todas las filas de la tabla terms
y mesa terms_relation
donde está taxonomía en la tabla terms_relation
es categ
? ¿Necesitaré dos consultas para esto o podría usar una declaración join
?
Aprender sobre [une SQL] (http://www.codinghorror.com/blog/2007/10/a-visual -explicación-de-sql-joins.html). – eggyal
Sí, obtenga información sobre las combinaciones de SQL. Aprenda en http://sqlzoo.net/ y http://sqlfiddle.com/ –