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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of if statments?

Status
Not open for further replies.

maverik59

Programmer
Oct 30, 2002
67
GB
In this query i want to count the number of occurances the staffid is = to the the page id (sometimes its not) is it possible to put in if statements?

SELECT first_name
,last_name
,page
,page_id
,staffid

FROM usertrack
,staff
WHERE page='/staff_details.cfm'
AND staff_id=staffid
if pageid=staffid count(*) AS ownvisit

 
SELECT first_name
,last_name
,page
,page_id
,staffid
,count(staffid)


FROM usertrack
,staff
WHERE page='/staff_details.cfm'
AND staff_id=staffid
GROUP BY first_name
,last_name
,page
,page_id
,staffid
HAVING count(staffid) > 0
-----------------------------------------------------------------
"The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'."
- unknown

mikewolf@tst-us.com
 
"HAVING"- Nice one.I'm learning a new command each day and i don't even do SQL. Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top