大虾帮我看看这个sql语句求解答
是这样的,要求要查询出不同两张表的字段。。然后表是没关联的
SELECT AD_URL from tp_index where AD_FROM = 1 and INDEX_TYPE = 'top' ORDER BY ORDERCONFIG LIMIT 1
这句SQL直接查询是可以
(SELECT AD_URL from tp_index where AD_FROM = 1 and INDEX_TYPE = 'top' ORDER BY ORDERCONFIG LIMIT 1)as aaa
想取个别名就不行了 然后要把查询出来的语句 放到另一个根据ID查询的sql里
SELECT BUS_ID AS groupid,BUS_TITLE AS groupname,BUS_END AS enddate,APP_PIC1 AS pic,APP_PIC2 AS pic2,(BUS_NEWPRICE / BUS_OLDPRICE) AS groupname FROM tm_businfo A WHERE A.BUS_ID =21 LIMIT 1
(SELECT AD_URL from tp_index where AD_FROM = 1 and INDEX_TYPE = 'top' ORDER BY ORDERCONFIG LIMIT 1)as aaa。 如果可以取别名 把这句加入上面那句其中一个逗号后面 是否就可以实现无关联查询了呢 求大侠指教~谢谢啦
------解决方案--------------------(SELECT AD_URL from tp_index where AD_FROM = 1 and INDEX_TYPE = 'top' ORDER BY ORDERCONFIG LIMIT 1)as aaa。
如果你这个语句的查询的结果是一行数据没问题,若果多行会报错。
------解决方案--------------------SELECT AD_URL from tp_index where AD_FROM = 1 and INDEX_TYPE = 'top' ORDER BY ORDERCONFIG LIMIT 0,1
这样绝对是查出一条记录,你试试