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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:40:56+00:00 2026-05-26T05:40:56+00:00

SELECT * FROM `restaurants` WHERE name LIKE ‘%string%’ SELECT * FROM `restaurants` WHERE address

  • 0
SELECT * FROM `restaurants` WHERE name LIKE '%string%'

SELECT * FROM `restaurants` WHERE address LIKE '%string%'

SELECT * FROM `menu_items` WHERE name LIKE '%string%'

I have these queries.

At the moment i show each query result seperatly. I would like to combine them all.

And all the results should have aliases with where they come from.
Example when it show a item/row from menu_items you should be able to see in the column “Type” that it is a ‘item’.

And ‘address’ for the restaurants address results and ‘name’ for the restaurants name results.

in MySQL

How can i do this?

My final output should look like this: You search after “s”

Spagetti - item
Sonus Suni - restaurant
Sunssisway 1232 - restaurant address
Delicous Spaga - item

So i would need to create my own alias column.. ‘item’ AS ‘Type’ etc..

  • 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-26T05:40:56+00:00Added an answer on May 26, 2026 at 5:40 am

    If you want to combine tables with different columns, you have to specify which columns you want.

    SELECT
        'Name' AS Type,
        Id AS R_Id,
        NULL AS I_Id,
        Name,
        Address,
        NULL AS M_Id
    FROM Restaurants
    WHERE Name LIKE '%string%'
    UNION ALL
    SELECT
        'Address' AS Type,
        Id AS R_Id,
        NULL AS I_Id,
        Name,
        Address,
        NULL AS M_Id
    FROM Restaurants
    WHERE Address LIKE '%string%'
    UNION ALL
    SELECT
        'Item' AS Type,
        NULL AS R_Id,
        Id AS I_Id,
        Name,
        NULL AS Address,
        M_Id
    FROM Menu_Items
    WHERE Name LIKE '%string%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

select * from myTable where myInt will not show any possible_keys when explaining the
SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY hrl.Frn) as Row, hrl.unq, hrl.LcnsId, hc.Business,hc.Name,hc.Phone,
SELECT * FROM myTable WHERE field1 LIKE 'match0' AND myfunc(t1.hardwareConfig) LIKE 'match1' Here is
SELECT * FROM [makes$] WHERE Corporate Name='Champion Enterprises, Inc.' I'm running this query on
select * from resource where ResourceID= 1 and ResourceKeyword in(gallery 1,1980) I have an
I have a table with gps locations of restaurants chains and would like to
I have a mySQL statement that looks like below. It tries to select all
SELECT * FROM CUSTOMERS WHERE RTRIM(ISNULL([SHORTNAME],'')) LIKE '%john%' I want to write this using
I have three inputs coming in from a form. They are name , neighborhoods
SELECT * FROM menu WHERE item_id = 1 OR item_id = 2 OR item_id

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.