id categories ext_categories
2 36 17,250
8 20 28
10 17 18
如果查询categories = 17
我能得到这样sql查询问题
id
2 (ext_categories field)
10
如何查询ext_categories
为id: 2
谢谢你的结果!
id categories ext_categories
2 36 17,250
8 20 28
10 17 18
如果查询categories = 17
我能得到这样sql查询问题
id
2 (ext_categories field)
10
如何查询ext_categories
为id: 2
谢谢你的结果!
ext_categories
是如何实现的?例如,您使用的一个varchar场和管道分隔的字符串(数字)的值与严格的格式
|n|...
,使您的表看起来像
id categories ext_categories
2 36 "|17|250|"
8 20 "|28|"
10 17 "|18|"
呢?
如果是这样,尝试
select * from table where categories = 17 OR ext_categories like '%|250|%'
你在找组?
select id,ext_categories From YOURTABLENAME group by id,ext_categories
我想我已经迷失了你对你问题的最新更新,我的答案目前无效,请解释更多 – 2011-01-08 07:38:31
想在结果中包含ext_categories
?或者您希望根据ext_categories
的ID从外部表中获取字段?
如果以后;
$sql = "SELECT * FROM table WHERE categories = 17 OR ext_categories =17 LEFT JOIN ext_category_table on ext_category_table.ext_category = ext_categories"
更新,它只有1表 – love 2011-01-08 07:49:58
如果你想简单地获取ID = 2 ext_category然后尝试“从表中选择ext_categories其中id = 2” – 2011-01-08 07:37:33
不要把多个值到一个列!这违反了数据库设计的第一种正常形式 - 这是一个很大的禁忌。它也试图处理这种数据时创建各种凌乱的代码....只是**不要**这样做! – 2011-01-08 08:54:44