0

First you must know: I have two tables "USERS" and "SONGS"

How is possible to check some conditions and place the result on a temp column? For example foreach song in result of select must be calculate the bool and add it to temp column so I can do other calculations then and make it the primary order......

$USER = SELECT * FROM USERS WHERE SOMECONDITION

SELECT * FROM SONGS
------
(
IF SONGS.LANG  LIKE $USER[LANG]  THEN TEMPCOLUMN.ADD "1" ELSE TEMPCOLUMN.ADD 0
IF SONGS.GENR1 LIKE $USER[GENR1] THEN TEMPCOLUMN.ADD "1" ELSE TEMPCOLUMN.ADD 0
IF SONGS.GENR2 LIKE $USER[GENR2] THEN TEMPCOLUMN.ADD "1" ELSE TEMPCOLUMN.ADD 0
)
------
ORDER BY TEMPCOLUMN DESC
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Stavros Koureas
  • 1,126
  • 12
  • 34

1 Answers1

1

This should do the same thing:

SELECT * FROM SONGS
ORDER BY
  SONGS.LANG LIKE $USER[LANG] DESC,
  IF SONGS.GENR1 LIKE $USER[GENR1] DESC,
  IF SONGS.GENR2 LIKE $USER[GENR2] DESC;
Jimmy T.
  • 4,033
  • 2
  • 22
  • 38