sql - select from table values by data from another table -
i have 2 tables
products
id | property1 | property2|property3 |category --------------------------|-------------------- 1 | trousers | red |uk | 1 2 | shoes | blue |usa | 2 3 | shoes | red |ru | 1
categories
id | property1 | property2 | property3 --------------------------------------- 1 | 1 | 1 | 0 2 | 1 | 0 | 1
i need select products values that have been marked 1 in products.
select `products` category = 1 values id, ... {plus have been marked 1 in 'categories'}
i need result looks
id | property1 | property2 | ---------------------------- 1 | trousers | red | 3 | shoes | red |
i don't need data or broke existing php-code. goal of query array
[0] => ['id'] => '1' ['property1'] => 'trousers' ['property2'] => 'red' [1] => ['id'] => '3' ['property1'] => 'shoes' ['property2'] => 'red'
by single query
select id,property1,property2 products category = 1
Comments
Post a Comment