开发者

How might I retrieve unique records from this table?

I have two tables: CardInfo and CardItems, so each CardInfo may have multiple CardItems. I need a SQL query to fetch unique records from CardInfo on the basis of some conditions which relates with both CardInfo and CardItems tables.

select c.* from CardInfo c, CardItems ci
where c.cr_no = ci.cr_no and ci.wc_id = 'test'

The 开发者_运维问答above query return duplicate records. Please suggest a solution.


you can remove duplicate records with DISTINCT

select distinct c.* from CardInfo c, CardItems ci
where c.cr_no = ci.cr_no and ci.wc_id = 'test'


   select c.* from cardinfo as c innerjoin carditems as ci
        on c.cr_no=ci.cr_no
where ci.wc_id = 'test'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜