开发者

Return true for rows that have positive value

开发者 https://www.devze.com 2022-12-20 02:57 出处:网络
I hav开发者_开发百科e a problem with emphasizing an advertisement -need to have to different designs for enhanced and non-enhanced ad\'s!

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

精彩评论

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