Jump to content
  • 0
Sign in to follow this  
Followers 0

PHP query help

Question

Posted

At the moment I have a query that looks like this

[CODE]
'SELECT IF
( table.competition
IN
(
\'column1\',
\'column2\',
\'column3\',
\'column4\'
),
\'First\',
table.competition
)
AS competition,
--- lots more code ---
GROUP BY competition
ORDER BY FIELD(table.competition,\'First\',\'FA Cup\',\'League Cup\') ASC
;');
[/CODE]

This basically takes a lot numbers from columns 1,2,3,4 adds them up and displays them under First. Is it possible to add another if to the start of the query? I want to take info from columns 5 and 6 but this has to go under a different column to First.

[CODE]
SELECT IF
( table.competition
IN
(
\'column5\',
\'column6\'
),
\'Second\',
table.competition
)
[/CODE]

Then the ORDER BY FIELD would change to

[CODE]
ORDER BY FIELD(table.competition,\'First\',\'FA Cup\',\'League Cup\',\'Second\') ASC
[/CODE]

Does anyone know if that be done? :blush:

Share this post


Link to post
Share on other sites

1 answer to this question

  • 0

Posted

I suspect you'd get more answers here if you provided a bit more info or changed your title to reflect sql. Did you try stackoverflow?

Normally if i need a conditional select I run php if statements. it's a little more forgiving than sql select if.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.