Jump to content


PHP query help

  • Please log in to reply
1 reply to this topic

#1 marklcfc



  • Joined: 30-March 05

Posted 16 February 2013 - 14:17

At the moment I have a query that looks like this

			( table.competition
		AS competition,
      --- lots more code ---
		GROUP BY competition
		ORDER BY FIELD(table.competition,\'First\',\'FA Cup\',\'League Cup\') ASC

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.

			( table.competition

Then the ORDER BY FIELD would change to

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

Does anyone know if that be done? :blush:

#2 ajcdotme


    General Nitwit

  • Joined: 17-November 11
  • Location: Ligonier, PA
  • OS: OSX, Centos 6, Ubuntu, SmartOS, Windows Server
  • Phone: Nokia Lumia 822

Posted 16 February 2013 - 17:23

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.

Click here to login or here to register to remove this ad, it's free!