id categories ext_categories
2 36 17,250
8 20 28
10 17 18
if query categories = 17 I can get results like this
id
2 (ext_categories field)
10
How to query ext_categories for id: 2
Thank you!
id categories ext_categories
2 36 17,250
8 20 28
10 17 18
if query categories = 17 I can get results like this
id
2 (ext_categories field)
10
How to query ext_categories for id: 2
Thank you!
How is the field ext_categories implemented? For example, are you using a varchar field and pipe-delimited string (of numbers) as values with the strict format
|n|...
so that your table looks like
id categories ext_categories
2 36 "|17|250|"
8 20 "|28|"
10 17 "|18|"
instead?
If so, try
select * from table where categories = 17 OR ext_categories like '%|250|%'
are you looking for group by?
select id,ext_categories From YOURTABLENAME group by id,ext_categories
You want to include ext_categories in the results? Or you want a field from a foreign table based on the ID of ext_categories ?
If the later;
$sql = "SELECT * FROM table WHERE categories = 17 OR ext_categories =17 LEFT JOIN ext_category_table on ext_category_table.ext_category = ext_categories"