Page 1 of 1 1
Topic Options
#110436 - 2003-12-15 10:11 PM SQL Select Statement
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Need I say more, why is making up a working SQL Statement so hard.

This is striaght from MS Access SQL Viewer.

Code:
SELECT Groups.Command, Groups.GroupName
FROM Groups
WHERE (((Groups.Command)="BackFolder") AND ((Groups.GroupName)="Medical Records"));



Of course it does not work, and what ever I try fails, what should I be looking for to get this working. Apart from a new Job.

I have a Table called "Groups", Fields called "Command" and "GroupName".

Thanks

Top
#110437 - 2003-12-15 10:30 PM Re: SQL Select Statement
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Well, this should do it i quess.
not 100% sure about the and statement though.

Code:

Use DB_name
SELECT Command, GroupName
FROM Groups
WHERE Command = 'BackFolder' and GroupName = 'Medical Records'



Can't test right now, cause I don't got sql on my laptop.


Edited by R2D2 (2003-12-15 10:32 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#110438 - 2003-12-15 10:31 PM Re: SQL Select Statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You're using way too many parentheses and doubel quotes instead of single quotes
Code:

SELECT Groups.Command, Groups.GroupName
FROM Groups
WHERE Groups.Command='BackFolder' AND Groups.GroupName='Medical Records';


or
Code:

SELECT Command, GroupName
FROM Groups
WHERE Command='BackFolder' AND GroupName='Medical Records'


However, this query does not make sense as the return will be zero or more recordsets containing only the words "BackFolder" and "Medical Records".


Edited by sealeopard (2003-12-15 10:33 PM)
_________________________
There are two types of vessels, submarines and targets.

Top
#110439 - 2003-12-15 10:32 PM Re: SQL Select Statement
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Thanks that worked a treat.

Why does Access put all the (( in, and use TableName.Colum Name. ???

Top
#110440 - 2003-12-15 10:36 PM Re: SQL Select Statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Becasue it's technically correct. Leaving the table names off is just a shortcut.
_________________________
There are two types of vessels, submarines and targets.

Top
#110441 - 2003-12-16 05:50 AM Re: SQL Select Statement
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

A tip for you.. If I may.

Go into Enterprise Manager, Your Database, Views.. Create a new View (you are not going to save it).. But anyway, it will give you the results you are looking for in a Microsft Access kind of way. However, the results will work perfectly in SQL.

BTW, you can you also work with SQL Server using Access under a .ADP File format too.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.055 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org