Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to select a specific number of two fields?

Author  Topic 

JohnP26
Starting Member

1 Post

Posted - 2011-11-30 : 17:51:48
Hi all,
I wonder how I can select a specific number of two fields in MySQL.
For example, I want to select 50 women and 90 men in the sex field of members table, but I can not do it.
Can you show me an example?

Thank you

pduffin
Yak Posting Veteran

68 Posts

Posted - 2011-11-30 : 18:28:44
Sorry this is a MS SQL site.
You could try using the TOP statement though.

Likes to run, hates the runs!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-01 : 00:24:16
quote:
Originally posted by JohnP26

Hi all,
I wonder how I can select a specific number of two fields in MySQL.
For example, I want to select 50 women and 90 men in the sex field of members table, but I can not do it.
Can you show me an example?

Thank you



use LIMIT

take seperate queries for women and men with LIMIT for 50 and 90 records. then merge them using UNION ALL/UNION

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -