sql Query - syntax please


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: sql Query - syntax please

  1. #1
    Join Date
    Feb 2005
    Posts
    22

    Unhappy sql Query - syntax please

    hi

    I am searching a sql database using MS Visual Studio .net 2003.

    this is my query so far:

    SELECT FirstName, LastName, PhoneExt, Phone, Date1 AS [Start Date], Date2 AS [Leave Date], Ref2, Ref3, CallPrompt AS Title
    FROM dbo.Client
    WHERE (Phone IS NULL) AND (PhoneExt IS NULL) OR
    (Phone LIKE 'tb%')
    ORDER BY LastName

    this brings up data

    like this

    Phone Phone EXt
    null null
    tbc 7802
    tba null

    But what I really want is:

    Phone Phone EXT
    null null
    tba null

    meaning if phone has tb% and a no in the phone ext field I don't want it.

    can someone show me what to do please.

    thanks
    Dianne

  2. #2
    Join Date
    Aug 2005
    Location
    Kent, England
    Posts
    29
    SELECT FirstName, LastName, PhoneExt, Phone, Date1 AS [Start Date], Date2 AS [Leave Date], Ref2, Ref3, CallPrompt AS Title
    FROM dbo.Client
    WHERE ((Phone IS NULL) OR (Phone LIKE 'tb%'))
    AND (PhoneExt IS NULL)
    ORDER BY LastName

  3. #3
    Join Date
    Feb 2005
    Posts
    22

    Solved - syntax

    thanks Trevor

    exactly what I wanted, I am struggling with the order to put things in.

    cheers
    Dianne

Similar Threads

  1. SQL Query Fails on NT System
    By Ken D. in forum VB Classic
    Replies: 2
    Last Post: 09-04-2002, 12:25 AM
  2. Syntax Error Updating SQL Server Table
    By Ralf in forum Database
    Replies: 26
    Last Post: 08-08-2002, 09:58 AM
  3. SQL Query across a network
    By Andy Jackson in forum VB Classic
    Replies: 1
    Last Post: 04-28-2002, 09:41 AM
  4. IIF in SQL Query Analyzer
    By Jeff Johnson in forum Database
    Replies: 3
    Last Post: 04-30-2001, 03:42 PM
  5. SQL server administrative knowledge
    By Becky in forum Database
    Replies: 1
    Last Post: 07-11-2000, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center