Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2010
    Posts
    39

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    since you don't allow NULL ...
    Code:
    SELECT...
      FROM articles
     WHERE a_image > ''
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2010
    Posts
    39
    that code is not working in my phpmyadmin

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jul 2010
    Posts
    39
    Thanks r937 as always, actually it works, you re genius as always

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •