query example request
Updated
Hello all,
MySQL here.
Let's say we have 3 tables.
TableA , TableB , TableC .
TableB relates with foreign keys, TableA and TableC .
I would like to: List some data from TableA and TableC BUT, that data should be ordered by some column of TableB .
Can I have an example of the above so that I can study it and try to transform to my needs?
Thanks a lot. MEM
mysql允许你按未选择的colums命令,所以你可以加入你的表
select ta.somefield, tc.somefield
from TableA ta INNER JOIN TableC tc on tc.somefield=ta.somefield
INNER JOIN TableB tb on tb.somefield=ta.somefield
ORDER by tb.somefield
SELECT TABLEA.fieldnames, TABLEC.fieldnames FROM TABLEA, TABLEB, TABLEC WHERE TABLEA.PRIMARY=TABLEB.TABLEA_PRIMARY AND TABLEC.PRIMARY=TABLEB.TABLEC_PRIMARY ORDER BY TABLEC.fieldname DESC
select
tA.blah,
tA.goop,
tC.schmarr,
tC.broigle
from
tB
join tA on tA.joincol1 = tB.joinCol1
join tC on tC.joinColx = tB.joinColx
order by
tc.schmarr
链接地址: http://www.djcxy.com/p/94296.html
下一篇: 查询示例请求