Jump to content

[SOLVED] Returning only one entry when multiple ones show up


Recommended Posts

Hi all,

 

I put this into the MSSQL forum also, but it'll relate to MySQL too. I'm running an SQL query that returns the following results:

 

Value    FirstName Surname Number

NULL      Mel          Brooks    4       

1001      JIm          Jones      9652       

13        JR            Ewing      5       

13        JR            Ewing      9651       

2          S            R          2 

5678      Euan        S          6       

8888      John        Ryan      3 

 

 

But I only want JR Ewing to show up once. Could anyone advise me on how to do this? I've tried using

 

SELECT DISTINCT (Value), FirstName, SurName etc

 

..but it still shows up twice, as JR Ewing has 2 entries in the Number column.

 

Can anyone help?

Cheers

Woolyg

If the numbers are unimportant, you can group by Value, FirstName, Surname, and simply not select the Number.  The right query really depends on what you want to do with the Number column, which appears for each duplicate.

Cheers for the help guys.

 

I went and bothered my resident SQL query guru (he wasn't happy, lemme tell ya) and he showed me the way you can call info from a table (say, table 'cards' defined as 'C') for one data instance using C1, then the next data instance using C2, and in the WHERE statement defining how to retrieve the C1 and C2 info.

 

All highly confusing for me, but it made sense eventually!

 

Solved- cheers.

Woolyg

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.