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

  • Home
  • SEARCH
  • 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 6542899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:16:55+00:00 2026-05-25T11:16:55+00:00

I have 2 tables I need to query with similar contents but differing field

  • 0

I have 2 tables I need to query with similar contents but differing field names.

I’m wanting to merge the following 2 queries into 1 so that I have 1 set of results.

The 2 queries are:

  SELECT 
    bookings.booking_name,
    bookings.booking_email,
    bookings.booking_mobile
  FROM 
    bookings   
  WHERE 
  ( bookings.booking_email LIKE "%' . $_POST['val'] . '%"
  OR 
    bookings.booking_name LIKE "%' . $_POST['val'] . '%"
  OR 
    bookings.booking_mobile LIKE "%' . $_POST['val'] . '%"
  )


SELECT 
    purchases.customer_name,
    purchases.customer_email,
    purchases.customer_phone
FROM 
 handbags
WHERE   
  ( purchases.customer_email LIKE "%' . $_POST['val'] . '%"
  OR 
    purchases.customer_name LIKE "%' . $_POST['val'] . '%"
  OR 
    purchases.customer_phone LIKE "%' . $_POST['val'] . '%"
  )

How is this sort of thing accomplished so that in my result customer_email and booking_email can be accessed simply by ’email’.

  • 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-25T11:16:56+00:00Added an answer on May 25, 2026 at 11:16 am

    Combine the two queries with the UNION operator, and give the columns matching names.

    (SELECT 
      bookings.booking_name AS name,
      bookings.booking_email AS email,
      bookings.booking_mobile AS phone
    FROM 
      bookings   
    WHERE 
    ( bookings.booking_email LIKE "%' . $_POST['val'] . '%"
      OR 
      bookings.booking_name LIKE "%' . $_POST['val'] . '%"
      OR 
      bookings.booking_mobile LIKE "%' . $_POST['val'] . '%"
    ))
    UNION
    (
    SELECT 
      purchases.customer_name AS name,
      purchases.customer_email AS email,
      purchases.customer_phone AS phone
    FROM 
     handbags
    WHERE   
    ( purchases.customer_email LIKE "%' . $_POST['val'] . '%"
      OR 
      purchases.customer_name LIKE "%' . $_POST['val'] . '%"
      OR 
      purchases.customer_phone LIKE "%' . $_POST['val'] . '%"
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help with a query that I wrote: I have three tables Company id
I have two tables described below. What I need is a single query that
I need help with a MySQL query. I have three tables: `product_category` ( `id`
Need some help with a query.. I have three tables. Source id name 1
I need a query which can do the following operation. I have a table
I have a query that does what i want joining table but i need
I have 3 different transaction tables, which look very similar, but have slight differences.
I have a query similar to the following: SELECT CASE WHEN (GROUPING(Name) = 1)
I have three table I need to query table 1,2 and 3 and select
I have a rather large table which I need to query for a reporting

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.