Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending a 'group' field to records

Status
Not open for further replies.

basildon

Programmer
Oct 22, 2001
58
GB
I have a large database of businesses which contains various pieces of information about each company (e.g. the number of employees that work there)

Is there a way, using 1 query, of selecting for example

500 companies of between 1 and 5 employees and
300 companies of between 10 and 50 employees

I have been using LIMIT, but as far as I know this will only let me do the above as 2 seperate queries.

ALSO is it possible to append a flag to the SELECTed records (e.g. those records that have between 1 and 5 should have an extra field added on containing '1 to 5' and the 10 to 50 employee records should also be appropriately flagged).

Any help on either part would be much appreciated as current method is very laborious esp. when there are dozens of cells.
 
Hi your query could be of the type


select * from companies where employees between 1 and 5 or employees between 10 and 50 LIMIT 500

regards Ron
 
Thanks Ron

This will just give me a spread of 1 to 5 employees records and 10 to 50 employees records.

I was looking for an exact number of each with 1 query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top