Re: Help - select syntax if else
You don't even need the check field you can just directly check the contents of the image field. Although I'm not sure if you are trying to set a filter or display something different. If you want to display a conditional on a field then you need to specify that field directly. select *,if(image,1,0) as ImagePresent from foo1 where ... If you don't want to spell out all of the fields, that's the easiest syntax. You'll can all your fields plus an extra column named ImagePresent that will be the same as your check column. You could just as easily have it show the image number instead of a 1 or 0. select *,if(image,image,no image) as ImageNumber from foo1 where ... On Wednesday, January 8, 2003, at 08:27 AM, Svens Klave wrote: so I want to make query select * from foo1 where [so is it possible to make some if check=1 then image is image but if check=0 then into image goes other content for example noimage] -- Brent Baisley Systems Architect Landover Associates, Inc. Search Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Help - select syntax if else
* Svens Klave Can anybody help me with select query I can try. how to do this: I have table foo1 with two fields image check | image | check | | 6782 | 0 | | 2732 | 1 | | 6734 | 1 | so I want to make query select * from foo1 where [so is it possible to make some if check=1 then image is image but if check=0 then into image goes other content for example noimage] I mean I need to check if there is 0 or 1 and so if check is 1 then show original number from image field but if there is 0 then it SELECT check,IF(check,image,'noimage') AS image FROM foo1; changes original content to noimage eh... a select statement can not change the database. The above SELECT will change the output of the image column according to your specification, but it will not change the database. You would need to use UPDATE for that: UPDATE foo1 SET image = 'noimage' WHERE check = 0; -- Roger - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Help - select syntax if else
On Wed, Jan 08, 2003 at 03:27:51PM +0200, Svens Klave wrote: Can anybody help me with select query how to do this: I have table foo1 with two fields image check | image | check | | 6782 | 0 | | 2732 | 1 | | 6734 | 1 | so I want to make query select * from foo1 where [so is it possible to make some if check=1 then image is image but if check=0 then into image goes other content for example noimage] I mean I need to check if there is 0 or 1 and so if check is 1 then show original number from image field but if there is 0 then it changes original content to noimage so then is possible to optimise my database otherwise I need to do this with web development scripts to check if I have image name like in image field so its sucks so maybe somebody can help me with that ok Good Day Svens, You can permanently change the database using the following query: UPDATE foo1 SET image='noimage' WHERE check=0; Cheers! -- Zak Greant [EMAIL PROTECTED] | MySQL Advocate | http://zak.fooassociates.com Using and Managing MySQL MySQL Training: Washington DC, March 17-21, 2003 Visit http://mysql.com/training for more information Public Service Announcement: Sincere Choice (http://sincerechoice.org) - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Help - select syntax if else
On 8 Jan 2003, at 15:27, Svens Klave wrote: | image | check | | 6782 | 0 | | 2732 | 1 | | 6734 | 1 | so I want to make query select * from foo1 where [so is it possible to make some if check=1 then image is image but if check=0 then into image goes other content for example noimage] If I'm understaning you correctly, you want something like SELECT IF(check, image, 'noimage') AS image FROM foo1; -- Keith C. Ivey [EMAIL PROTECTED] Tobacco Documents Online http://tobaccodocuments.org Phone 202-667-6653 - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php