CodingMySQL - Help :(

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  steve   
 To:  Peter (BOUGHTONP)     
30653.3 In reply to 30653.2 
Oooh I can understand what you have done there, it is GOOD

I cannot however get it to run :( Syntex error! I have it to

sql code:
CREATE TEMPORARY TABLE stevealikes
                                AS
                                (SELECT uid, 1 AS hair, 0 AS beard, 0 AS eyes FROM people_main WHERE des_haircolour = 'black')
                                UNION
                                (SELECT uid, 0 AS hair, 1 AS beard, 0 AS eyes FROM people_main WHERE des_facialhair = 'long')
                                UNION
                                (SELECT uid, 0 AS hair, 0 AS beard, 1 AS eyes FROM people_main WHERE des_eyecolour = 'green');
 
                                 
                                SELECT uid, hair, beard, eyes, SUM(hair,beard,eyes) AS total
                                FROM stevealikes
                                GROUP BY uid, hair, beard, eyes
                                ORDER BY total DESC;


To work with stuff, but alas, it still errors out :'S The top create-bit seems to run through without errors. It doesn't like me adding the SELECT bottom part XD

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  steve      
30653.4 In reply to 30653.3 
Hmmm, dunno if PHP allows composite queries - have you tried running them individually, one after the other?

Or even directly in a MySQL terminal to check the code is okay...
0/0
 Reply   Quote More 

 From:  steve   
 To:  Peter (BOUGHTONP)     
30653.5 In reply to 30653.4 
I THINK I DID IT XD

The sum(blah,blah,blah) as total wasn't valid - I bodged it to;

(sum(blah)+sum(blah)+sum(blah)) as total

And yay :D

0/0
 Reply   Quote More 

 From:  steve   
 To:  Peter (BOUGHTONP)     
30653.6 In reply to 30653.4 
omg DOUBLE HELP PETER :C

Thankyou very much as I have made it work :D

BUT! How do I make it so it only reports one of each ID?

It's turning up some IDs several times in each :'S

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  steve      
30653.7 In reply to 30653.6 
Yay. :D


Just change it to SELECT DISTINCT ... and it should return only one per person.
0/0
 Reply   Quote More 

 From:  steve   
 To:  Peter (BOUGHTONP)     
30653.8 In reply to 30653.7 
Yay :D



Hooray XD!

0/0
 Reply   Quote More 

Message 30653.9 was deleted

Reply to All    
 

1–9

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