Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:44:12+00:00 2026-06-04T07:44:12+00:00

How would I get the banner name? If you look at the DB below

  • 0

How would I get the banner name? If you look at the DB below you will see that this bring back everything apart from the actual banner.name?

Also I presume that it should check that the banner status to check it is enabled.

BEFORE:

SELECT * 
FROM banner_image bi 
LEFT JOIN banner_image_description bid ON (bi.banner_image_id  = bid.banner_image_id) 
WHERE
   bi.banner_id = '".$banner_id."' 
   AND bid.language_id = '".$this->config->get('config_language_id')."'

Array ( 
    [0] => Array ( 
        [banner_image_id] => 1 
        [banner_id] => 1 
        [link] =>
        [image] => data/banners/test.jpg 
        [language_id] => 1 
        [title] => Test banner 
    ) 
)

AFTER:

SELECT
   bi.*,
   b.name 
FROM
   banner b,
   banner_image bi 
LEFT JOIN banner_image_description bid ON (bi.banner_image_id  = bid.banner_image_id) 
WHERE
   b.banner_id = '".$banner_id."' 
   AND bi.banner_id = '".$banner_id."' 
   AND bid.language_id = '".$this->config->get('config_language_id')."'

Array ( 
    [0] => Array ( 
        [banner_image_id] => 1 
        [banner_id] => 1 
        [link] => 
        [image] => data/banners/test.jpg 
        [name] => Banner heading 
    ) 
)

DB Structure:

CREATE TABLE IF NOT EXISTS `banner` (
  `banner_id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) COLLATE utf8_bin NOT NULL,
  `status` tinyint(1) NOT NULL,
  PRIMARY KEY (`banner_id`)
);

CREATE TABLE IF NOT EXISTS `banner_image` (
  `banner_image_id` int(11) NOT NULL AUTO_INCREMENT,
  `banner_id` int(11) NOT NULL,
  `link` varchar(255) COLLATE utf8_bin NOT NULL,
  `image` varchar(255) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`banner_image_id`)
);

CREATE TABLE IF NOT EXISTS `banner_image_description` (
  `banner_image_id` int(11) NOT NULL,
  `language_id` int(11) NOT NULL,
  `banner_id` int(11) NOT NULL,
  `title` varchar(64) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`banner_image_id`,`language_id`)
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:44:14+00:00Added an answer on June 4, 2026 at 7:44 am

    I think this will do what you want:

    SELECT *
    FROM
        banner b
        INNER JOIN banner_image bi ON b.banner_id = bi.banner_id
        INNER JOIN banner_image_description bid ON bi.banner_image_id = bid.banner_image_id
    WHERE
        b.banner_id = '". $banner_id ."'
        AND b.status = TRUE
        AND bid.language_id = '". $this->config->get('config_language_id') ."'
    

    I would avoid using SELECT * and instead, explicitly list out each column you actually want to fetch.

    One reason I think you were having trouble is that you used a comma (implicit join) to join in the banner table, but you didn’t specify a join condition. You would have needed a condition in your WHERE clause like b.banner_id = bi.banner_id. But it would be better to use explicit INNER JOIN syntax.


    I don’t see a reason for using a LEFT JOIN instead of an INNER JOIN in this query. In the WHERE clause, you specify a condition that must be met in the banner_image_description table in order for a row to be returned. If there is no corresponding row in that table (which is the purpose of a LEFT JOIN), then there will be no row returned. So I switched them to INNER JOIN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would get details from two MySQL tables tables structure as shown table:App |AppID|AppName|AppType|
How would get find an average from an array? If I have the array:
Following is how you would get the current solution directory from an add-in: _applicationObject
I'm looking for a method or an event that would get fired when a
Can someone please shed some light on how I would get this to work:
I'm trying to write a recursive function that would get some string, as well
I don't see that method in there... I just put the iAd banner in
On the site: ukrainiansecret.com I would like to get rid of that green right
I have this query below that I've rewritten a dozen different ways, yet I
When running the Microsoft Application Verifier i would get an error 0202 on shutdown:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.