MySql查询两张相同表,合并成一组数据,并区分数据的不同
时间:2021-07-01 10:21:17
帮助过:4人阅读
*
FROM
(
SELECT
`title`,
‘img‘ AS TYPE,
`id`,
`orderid`,
`posttime`,
`content`,
`description`,
`checkinfo`,
`linkurl`,
`picurl`,
`classid`
FROM
`#@__infoimg`
WHERE
parentid != 2
AND
title LIKE ‘%$searchKey%‘
AND
(classid = $CID
OR parentstr
LIKE ‘%,$CID,%‘)
UNION ALL
SELECT
`title`,
‘list‘ AS TYPE,
`id`,
`orderid`,
`posttime`,
`content`,
`description`,
`checkinfo`,
`linkurl`,
`picurl`,
`classid`
FROM
`#@__infolist`
WHERE
checkinfo = TRUE
AND
title LIKE ‘%$searchKey%‘
AND
(classid = $CID
OR parentstr
LIKE ‘%,$CID,%‘)
) AS tab
ORDER BY
tab.orderid
DESC
要注意有可能在设置中
UNION 特别的方法不能使用,这些方法有肯能出现数据的泄露。所以会部分阻止使用。
MySql查询两张相同表,合并成一组数据,并区分数据的不同
标签:link 不能 nbsp bsp union 使用 不同 parentId sele