开发者

Return true for rows that have positive value

I hav开发者_开发百科e a problem with emphasizing an advertisement - need to have to different designs for enhanced and non-enhanced ad's!

My table is like this:

id   int(11) UNIQUE  // the unique id of the row
adresse   text   // the adress of an advertisement
fremhaevninger  int(11)   // the number of emphasizings of the ad
dato   datetime  // when the row was added

I need to have a script, that can return me e.g. a variable like

$enhanced = 1;

if 'fremhaevninger' > 0 - else

$enhanced = 0;

NOTE: 'fremhaevninger' can be anything from 0 to 99.999.999.999

Is that possible?


Use IF():

SELECT
  otherfields,
  IF(fremhaevninger > 0, 1, 0) AS enhanced
FROM
  ....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜