|
-
Jul 27th, 2007, 05:13 AM
#1
Thread Starter
Addicted Member
Query Problem [RESOLVED]
Hi, I am trying to execute th query below but keep getting the error below on MSSQL 2000. any ideas where i could be going wrong.
Code:
Select pb.name as name,
pb.cellnumber as cellnumber, pb.recordindex as pbindex,
pb.emailaddress as emailaddress,
gm.recordindex as groupindex,
gm.groupindex as gi
if gm.allowedbroadcast = 1,'Yes','No' as priv
if(gm.groupindex,'Member','Not Member') as ismember,
if(gm.allowedbroadcast = 1,'Privileged' ,'Normal') as Broadcast
FROM
groupmembers as gm LEFT
JOIN
phonebook as pb on (pb.recordindex = gm.phonebookindex)
WHERE
groupindex=34 order by gm.allowedbroadcast desc,
pb.name asc, pb.cellnumber asc
I get the error below
Line 6: Incorrect syntax near ','.
Line 7: Incorrect syntax near ','.
Line 8: Incorrect syntax near ','.
(0.300 sec)
Any help will be greatly appreciated.
Last edited by Paradox; Jul 30th, 2007 at 06:12 AM.
-
Jul 27th, 2007, 05:33 AM
#2
Lively Member
Re: Query Problem
hi
try this is work or not
Code:
Select pb.name as name,
pb.cellnumber as cellnumber, pb.recordindex as pbindex,
pb.emailaddress as emailaddress,
gm.recordindex as groupindex,
gm.groupindex as gi,
if gm.allowedbroadcast = 1,'Yes','No') as priv,
if(gm.groupindex,'Member','Not Member') as ismember,
if(gm.allowedbroadcast = 1,'Privileged' ,'Normal') as Broadcast
FROM
groupmembers as gm LEFT
JOIN
phonebook as pb on (pb.recordindex = gm.phonebookindex)
WHERE
groupindex=34 order by gm.allowedbroadcast desc,
pb.name asc, pb.cellnumber asc
-
Jul 27th, 2007, 05:44 AM
#3
Thread Starter
Addicted Member
Re: Query Problem
Still not working. Is this the way to implement IF conditions in MSSQL?
-
Jul 27th, 2007, 10:38 AM
#4
Re: Query Problem
No, I'm afraid it doesn't support If within queries... you need to use Case instead.
An explanation and example can be seen in Books Online, the web based version is here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|