If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Any possibilities for such queries ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-26-11, 09:38
linux1880 linux1880 is offline
Registered User
 
Join Date: Jul 2010
Posts: 39
Any possibilities for such queries ?

I have a table where user post articles, however sometimes they post images and some time they don't. I want to display one featured image only from the table below in the homepage and image should always available .

The problem is some articles don't have image and it looks blank. Is there any advice from experts ?

CREATE TABLE `articles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`a_title` varchar(255) NOT NULL,
`a_description` varchar(400) NOT NULL,
`a_content` text NOT NULL,
`a_views` int(11) NOT NULL DEFAULT '0',
`a_thumbnail` varchar(255) CHARACTER SET latin1 NOT NULL,
`a_image` varchar(255) CHARACTER SET latin1 NOT NULL,
`a_tags` varchar(50) NOT NULL,
`a_author` varchar(120) NOT NULL,
`a_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=46 DEFAULT CHARSET=utf8
Reply With Quote
  #2 (permalink)  
Old 02-26-11, 10:17
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
since you don't allow NULL ...
Code:
SELECT...
  FROM articles
 WHERE a_image > ''
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-26-11, 10:25
linux1880 linux1880 is offline
Registered User
 
Join Date: Jul 2010
Posts: 39
that code is not working in my phpmyadmin
Reply With Quote
  #4 (permalink)  
Old 02-26-11, 10:41
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
Quote:
Originally Posted by linux1880 View Post
that code is not working in my phpmyadmin
i'm terribly sorry, i am not familiar with the "is not working" error message
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 02-26-11, 20:06
linux1880 linux1880 is offline
Registered User
 
Join Date: Jul 2010
Posts: 39
Thanks r937 as always, actually it works, you re genius as always
Reply With Quote
Reply

Tags
mysql

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On