CodingSQL (ugh!)

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  THERE IS NO GOD BUT (RENDLE)  
 To:  Mikee      
30338.2 In reply to 30338.1 
You want to ask one question and get two answers? Why would you want to do that? Are you working under some kind of bizarre BOFH regime where you only get to run one query, or are you just mental?

0/0
 Reply   Quote More 

 From:  Mikee   
 To:  THERE IS NO GOD BUT (RENDLE)     
30338.3 In reply to 30338.2 
Slightly mental.



[Mwah]
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Mikee      
30338.4 In reply to 30338.1 
Not sure if this will work, but hopefully its along the right lines:
SQL code:
SELECT id, SUM(questiontext IN (...)) AS match_count
FROM mytable
WHERE surveyid = 1
GROUP BY id

Basically, you just get all rows with a matching surveyid and count the number of matching questions.

Then you just use the query's recordcount to supply you with the first count. (which in PHP I think you use the sizeof() function for)

But like I said, I'm not sure that SQL is the precise right way of doing it.
0/0
 Reply   Quote More 

 From:  Ben (BENLUMLEY)  
 To:  Peter (BOUGHTONP)     
30338.5 In reply to 30338.4 
if that doesn't work, an if will make it work.
0/0
 Reply   Quote More 

Reply to All    
 

1–5

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats