Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 5th, 2004, 06:53 AM
Authorized User
 
Join Date: Nov 2004
Location: Karachi, , Pakistan.
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query for NOT LIKE!

Would you people plz let me know if there exists any query for SELECTING ALL FROM A SPECIFIC TABLE EXCEPT WHERE THE ID IS LIKE ANY(specific word)??

Suppose i want to select all the users from the table whom status is not inactive?
I know i could do it with selecting all where status is active. But i want to do it other way round.

Could anyone let me know plz!

Thanx!

Farzan Q.
BS(TeleCommunication)
Iqra University.
__________________
Farzan Q.
MS(TeleCommunication)
Mohammad Ali Jinnah University.
  #2 (permalink)  
Old November 5th, 2004, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

 where status NOT IN ('UC', 'ME', 'PEE')

  #3 (permalink)  
Old November 5th, 2004, 02:53 PM
Authorized User
 
Join Date: Nov 2004
Location: Karachi, , Pakistan.
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by stu9820
  where status NOT IN ('UC', 'ME', 'PEE')

You meant to say that the query goes like this
SELECT * FROM USERS WHERE STATUS NOT INACTIVE

AM I RITE?
Sorry i didnt get what is UC , ME , PEE???

Could you plz write whole query for me..
i will be thankful!

Farzan Q.
BS(TeleCommunication)
Iqra University.
  #4 (permalink)  
Old November 8th, 2004, 10:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

 Status should be a column name and you can have 'ACTIVE' or 'INACTIVE'.

ID Name Status
3 me ACTIVE
4 you INACTIVE

So, where status NOT IN 'INACTIVE' would pull 'me'

  #5 (permalink)  
Old November 8th, 2004, 11:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

Quote:
quote:You meant to say that the query goes like this
SELECT * FROM USERS WHERE STATUS NOT INACTIVE
What is the datatype of STATUS column, and what data is stored in it?
Quote:
quote:AM I RITE?
Sorry i didnt get what is UC , ME , PEE???
That was just an example about how it could be done.
Quote:
quote:Could you plz write whole query for me..
i will be thankful!
Until we see the structure of the table and the datatye of the columns involved, we could only suggest how to go about it. It would be better if you could post the information required to understand that better and in turn help you better.

Cheers!

_________________________
- Vijay G
Strive for Perfection
  #6 (permalink)  
Old November 9th, 2004, 03:23 PM
Registered User
 
Join Date: Nov 2004
Location: Bremen, GA, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to acetylene1
Default

SELECT * FROM TABLE_NAME WHERE COLUMN_NAME != 'STRING';
SELECT * FROM TABLE_NAME WHERE COLUMN_NAME NOT IN ('STRING1','STRING2','STRING3');
SELECT * FROM TABLE_NAME WHERE COLUMN_NAME = TRUE;

These all do pretty much the same thing, just in slightly different ways. The first does exactly what you asked. The second, the same but where the query returns everything except what you put in all three strings. The third is different because it addresses a different data type (boolean).

As far as the 'UC', 'ME', 'PEE' thing, just sound it out. It was a way of making an example that doubled as a joke.

Jeff Trent
System Administrator
SynchroNet, Inc.
  #7 (permalink)  
Old November 10th, 2004, 05:19 PM
Authorized User
 
Join Date: Nov 2004
Location: Karachi, , Pakistan.
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx alot Mr. Jeff Trent and stu9820. I tried the way you ppl told me...it worked both the ways with little amendments:) thanx alot ...thankyou very much!

Thanx Mr. Vijay for putting your efforts in posting and trying to help me. It already worked thats why i haven't posted the details you asked for...i m sorry for that:)

Farzan Q.
BS(TeleCommunication)
Iqra University.
  #8 (permalink)  
Old November 12th, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

That's okay.No Problem.

Glad that you are through.

Cheers!

_________________________
- Vijay G
Strive for Perfection


Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.