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 6715271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:35:42+00:00 2026-05-26T08:35:42+00:00

Possible Duplicate: Combining several database table together? I want from two database table get

  • 0

Possible Duplicate:
Combining several database table together?

I want from two database table get output like this:

One-week tour of Istanbul_1 | 88888 & 99999 $ 112233 $ 445566 | Three nights and two days | 15:29
One-week tour of Istanbul_2 | 55555 & 66666 $ 77777 | Three nights and two days | 12:03
One-week tour of Istanbul_3 | 11111 & 22222 $ 33333 $ 44444 | Three nights and two days | 12:03

These are my tables:

enter image description here
enter image description here

Update:

it give me this output: http://img708.imageshack.us/img708/2404/outputnz.gif but if i put in $find value “55555” for where output is as: http://img528.imageshack.us/img528/3576/outputnow.gif but i want out is as: http://img832.imageshack.us/img832/120/outputwant.gif . How is it?

$query = $this -> db -> query('
    SELECT
       @rownum := @rownum + 1 rownum,
       tour_foreign.id, 
       tour_foreign.name, 
       MIN(tour_foreign_residence.name_re) AS name_re, 
       tour_foreign.service, 
       tour_foreign.date_go, 
       tour_foreign.date_back, 
       tour_foreign.term,
       tour_foreign.useradmin_submit,
       tour_foreign.date_submit,
       GROUP_CONCAT( tour_foreign_residence.name_re 
                     ORDER BY tour_foreign_residence.name_re 
                     SEPARATOR " $ "
                   ) AS name_re_all
    FROM   tour_foreign 
      INNER JOIN tour_foreign_residence 
        ON ( tour_foreign.id = tour_foreign_residence.relation )
      JOIN (SELECT @rownum := 0) r
    WHERE  tour_foreign.name LIKE "%' . $find . '%" 
        OR tour_foreign_residence.name_re_all LIKE "%' . $find . '%"
    GROUP BY  tour_foreign.id ');

I get from above sql following error:

A Database Error Occurred
Error Number: 1054

Unknown column ‘tour_foreign_residence.name_re_all’ in ‘where
clause’

SELECT @rownum := @rownum + 1 rownum, tour_foreign.id,
tour_foreign.name, MIN(tour_foreign_residence.name_re) AS name_re,
tour_foreign.service, tour_foreign.date_go, tour_foreign.date_back,
tour_foreign.term, tour_foreign.useradmin_submit,
tour_foreign.date_submit, GROUP_CONCAT( tour_foreign_residence.name_re
ORDER BY tour_foreign_residence.name_re SEPARATOR ” $ ” ) AS
name_re_all FROM tour_foreign INNER JOIN tour_foreign_residence ON (
tour_foreign.id = tour_foreign_residence.relation ) JOIN (SELECT
@rownum := 0) r WHERE tour_foreign.name LIKE “%%” OR
tour_foreign_residence.name_re_all LIKE “%%” GROUP BY
tour_foreign.id

Filename:
D:\xampp\htdocs\system\database\DB_driver.php

Line Number: 330

  • 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-05-26T08:35:42+00:00Added an answer on May 26, 2026 at 8:35 am

    You need to group by something or the aggregate GROUP_CONCAT() will collect all rows into one:

    GROUP BY  tour_foreign.id 
    

    Use:

    $query = $this -> db -> query('
        SELECT
           @rownum := @rownum + 1 rownum,
           tour_foreign.id, 
           tour_foreign.name, 
           MIN(tour_foreign_residence.name_re) AS name_re, 
           tour_foreign.service, 
           tour_foreign.date_go, 
           tour_foreign.date_back, 
           tour_foreign.term,
           tour_foreign.useradmin_submit,
           tour_foreign.date_submit,
           GROUP_CONCAT( tour_foreign_residence.name_re 
                         ORDER BY tour_foreign_residence.name_re 
                         SEPARATOR " $ "
                       ) AS name_re_all
        FROM   tour_foreign 
          INNER JOIN tour_foreign_residence 
            ON ( tour_foreign.id = tour_foreign_residence.relation )
          JOIN (SELECT @rownum := 0) r
        WHERE  tour_foreign.name LIKE "%' . $find . '%" 
            OR tour_foreign_residence.name_re LIKE "%' . $find . '%"
        GROUP BY  tour_foreign.id ');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between Convert.tostring() and .tostring() Hi Carrying on from this question What
Possible Duplicate: combining two lamba expressions in c# I have two following expressions: Expression<Func<string,
Possible Duplicate: How to run a database script file from Delphi? I have a
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicate: How can I squash my last X commits together using git? I
Possible Duplicate: Compiling a java program into an exe Hi, I'd like to convert
Possible Duplicate: jQuery .load method not firing on IE9 In IE7 and IE8 this

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.