我试图让我的 SQL 结果按某个“点系统”排序。对于每个填写的字段,搜索结果都会获得一定的分数。在我的 SQL 末尾,我添加了以下 ORDER BY - 代码,但是,如果我将“1”数字之一更改为更高的数字,则搜索结果顺序不会更改。为什么那行不通?(在本例中将 bedrijfslogo-case 更改为 9):
多谢你们!
$sql .= " ORDER BY
case when ID is not null then 1 else 0 end +
case when username is not null then 1 else 0 end +
case when password is not null then 1 else 0 end +
case when voornaam is not null then 1 else 0 end +
case when achternaam is not null then 1 else 0 end +
case when telefoonnummerP is not null then 1 else 0 end +
case when emailP is not null then 1 else 0 end +
case when functie is not null then 1 else 0 end +
case when bedrijfsnaam is not null then 1 else 0 end +
case when bedrijfsslogan is not null then 1 else 0 end +
case when bedrijfslogo is not null then 9 else 0 end +
case when bedrijfsfoto is not null then 1 else 0 end +
case when bedrijfsfoto2 is not null then 1 else 0 end +
case when bedrijfsfoto3 is not null then 1 else 0 end +
case when bedrijfsfoto4 is not null then 1 else 0 end +
case when bedrijfsomschrijving is not null then 1 else 0 end +
case when bedrijfsspecialiteiten is not null then 1 else 0 end +
case when bedrijfsgeschiedenis is not null then 1 else 0 end +
case when openingstijden is not null then 1 else 0 end +
case when kvk is not null then 1 else 0 end +
case when straatnaam is not null then 1 else 0 end +
case when huisnummer is not null then 1 else 0 end +
case when postcode is not null then 1 else 0 end +
case when plaats is not null then 1 else 0 end +
case when nevenvestigingen is not null then 1 else 0 end +
case when telefoonnummer is not null then 1 else 0 end +
case when fax is not null then 1 else 0 end +
case when email is not null then 1 else 0 end +
case when website is not null then 1 else 0 end +
case when twitter is not null then 1 else 0 end +
case when facebook is not null then 1 else 0 end +
case when youtube is not null then 1 else 0 end +
case when linkedin is not null then 1 else 0 end +
case when hoofdrubriek is not null then 1 else 0 end +
case when subrubrieken is not null then 1 else 0 end +
case when merken is not null then 1 else 0 end +
case when diensten is not null then 1 else 0 end +
case when productsoorten is not null then 1 else 0 end +
case when brancheverenigingen is not null then 1 else 0 end
DESC";