如何编写查询来获取类似的记录,
我有两张表,如下所述,
现在,我想获取1行的记录 - 列dtls列表,如下面的查询
选择a.ID AS ID,A.Row_NO作为Row_NO,b。*作为b来自A a,B b
请帮我根据我的要求提取记录。
答案 0 :(得分:1)
使用LEFT JOIN或INNER JOIN(请参阅文档链接)
SELECT i.ID as ID, i.Row_NO as Row_NO, j.* AS j FROM A AS i
LEFT JOIN B AS j
ON i.Row_NO = j.Row_NO
顺便说一下,如果你不在表结构中使用大写字母,这个查询会更容易理解
答案 1 :(得分:1)
试试这个
SELECT
a.ID AS ID,
a.Row_NO as Row_NO,
b.ID AS bID,
b.Col_No,
b.Value
FROM A a
INNER JOIN B b ON (b.Row_No = a.Row_No);