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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:48:03+00:00 2026-06-01T08:48:03+00:00

Assume your connection from your web server to your DBA server is extremely slow,

  • 0

Assume your connection from your web server to your DBA server is extremely slow, and you need to do a series of three queries to handle a single web request. Is there a way to combine the queries into one? Assume the following scenario

person.id person.name
1         James
2         Stacy

.

country.id country.name
1          USA
2          UK

.

location.person_id location.country_id
1                  1
1                  2

The web form would post two variables, ie name=”James” country=”China” and you want to do the following

  • Does “James” exist, if not, insert james
  • Does “China” exist, if not, insert china
  • Does “James” live in “China”, if not insert relationship

ie something like

select person.id, country.id, location.person_id
from person, country, location
where
    person.name="James" and
    country.name="China" and
    person.id=location.id and country.id=location.country_id

The above query is not useful because it will return no records if either the person, or the country or the location does not exist.

I know that it would be possible to do this using a stored procedure but not all databases support stored procedures.

  • 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-01T08:48:05+00:00Added an answer on June 1, 2026 at 8:48 am

    The solution is very simple

    SELECT (SELECT person.id from person WHERE person.name = 'James') as Name,
           (SELECT country.id from country WHERE country.name="China") as Country,
           (SELECT location.person_id from location WHERE person.id = location.id and country.id = location.country_id and person.name = 'James' and country.name="China") as Location
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume you work on a remote server from a local emacs shell (started with
I need your suggest about data processing. My server is a data server (using
All the tutorials and examples I've found of XSLT processing seem to assume your
Assume you have a file which has been committed in your Git repo. You
Assume that you're working a x86 32-bits system. Your task is to implement the
Assume I have access to a SMB server at IP 1.2.3.4, how can I
I'm trying to type-check the commands I want to send to a server from
Assume your .NET-based development team is already using the following set of tools in
Assume I have a C# class like this: [XmlRoot(floors)] public class FloorCollection { [XmlElement(floor)]
Assume I have the following string: Hellotoevryone<img height=115 width=150 alt= src=/Content/Edt/image/b4976875-8dfb-444c-8b32-cc b47b2d81e0.jpg />Iamsogladtoseeall. 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.