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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:26:31+00:00 2026-05-23T12:26:31+00:00

Normally I make something like this. #1 first query while () : #2 2nd

  • 0

Normally I make something like this.

#1 first query
 while () :
    #2 2nd queries
    #3 3rd queries
 endwhile;

to get a result. Now I want to combine them in one query. How can be done with this.

Table#1
-------------------------------------------
SELECT 
UserID, UserName, CountryCode, StateCode, CityCode, VillageCode, UserRace, UserStatus, UpdateStatus 
FROM user_locality
WHERE CountryCode = '{$getCountryCode}'

Table#2
-------------------------------------------
SELECT 
* 
FROM user_addresses 
WHERE address_UserID = '{$UserID}'

Table#3
-------------------------------------------
SELECT 
phone_UserID, phone_m, phone_h, phone_o 
FROM user_phones 
WHERE phone_UserID  = '{$UserID}'

Thank you.

  • 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-23T12:26:32+00:00Added an answer on May 23, 2026 at 12:26 pm

    You’ll want to use the JOIN clause. There are different types of joins. I’m using LEFT JOIN below which will select all records from user_locality and try to match records from both user_addresses and user_phones.

    SELECT    *
    FROM      `user_locality`
    LEFT JOIN `user_addresses`
    ON        `user_addresses`.`address_UserID` = `user_locality`.`UserID`
    LEFT JOIN `user_phones`
    ON        `user_phones`.`phone_UserID` = `user_locality`.`UserID`
    WHERE     `user_locality`.`CountryCode` = '{$getCountryCode}'
    

    The one thing to point out this query will result in more than 1 row for each user that has more than 1 phone or address.

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

Sidebar

Related Questions

Something like this, would make the widget appear normally: Label(self, text = 'hello', visible
Normally you can do something like this for properties: public String s {get; set;
Normally, the UITableView is something like this: [ cell 1 ] [ cell 2
I have identified the query constructs my users normally use. Would it make sense
Normally, I've seen prototype functions declared outside the class definition, like this: function Container(param)
Normally you can print a string in C like this.. printf(No record with name
This seems like it should be obvious, but the solution is eluding me. Normally
I normally use scp to copy stuff, but now I'm trying to get used
In my websites normally I use Ajax, so the address is always something like
Normally you create a function using cfscript like: <cfscript> function foo() { return bar;

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.