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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:04:53+00:00 2026-06-08T19:04:53+00:00

I want to do a PDO request that will get informations from 2 different

  • 0

I want to do a PDO request that will get informations from 2 different tables, but things fastly get hard, i explain :

I have a first database table (flowers) that is organized like this (but it’s REALLY bigger than what I show to you) :

ID;       name;              price of format 1; price of format 2; name of other format 3; price of other format 3;
FLOW0001; big yellow flower; ;                  15,99;             more big format;        34,99; 
FLOW0002; little red flower; 5,99;              8,99;              ;                       ; 

… it goes on like this…

The second table (trees) is like this :

ID;       name;            name of format;  price of format;
TREE0001; OMG BIG TREE !;  F*** big format; 599,99; 
TREE0001; OMG BIG TREE !;  F*** even bigger format; 899,99; 
TREE0002; litte ugly tree; little format;   20,99; 

… it goes on like this…

The thing is that I want to “merge” these 2 tables and to show them togheter blended in a page like this :

while ($datas =$response->fetch()) //fetching the tables, they will be togheter and ordered by (their biggest) price. So, trees and flowers will blend. 
{
    // then echo the fetched datas. I will need to separate the prices and show them... some if/else based on pregmatches of the ID to know if it's an TREE or FLOW. 
}

How to blend this ? Igot no Ideas. The worst is that I will need to do a page system (50 per pages). On the page system and in the pages, all the duplicated trees will need to appear as only uniques trees… HELP !

  • 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-08T19:04:55+00:00Added an answer on June 8, 2026 at 7:04 pm

    You can use a union to get the data from both tables. just be sure that you are returning matching columns in both queries. So if in your first query you have the following data types int, text, varchar, decimal, decimal you will need to make sure that the second query gets those same column types otherwise the DB will have a hissyfit about it. You can use an order by clause on the end to sort the data from both queries nicely.

    Something like this should do the trick:

    select
        ID,
        name,
        price
    from
        flowers
    where
        // your clauses
    union   
    select
        ID,
        name,
        price
    from
        trees
    where
        // your clauses
    order by 3 desc
    

    Edit: You can group_concat() fields in them if you want, and yes, you will be able to do an explode() on them in your PHP. The default group_concat delimiter is a , (comma) so if you have commas in your fields, you will need to change it to something so that your explode works nicely.

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

Sidebar

Related Questions

I want to use pdo in my application, but before that I want to
I'm already using http://php.net/pdo so I can get whatever I want from the user
I want to use PDO but I'm not sure whether my hosting has set
I'm extending PDO and I want to throw exceptions from it. Should I make
I'm having trouble moving from MySQL SELECT methods to PDO methods. I want to
I want to be able to get some output from mysql stored procedure within
I want to install PDO driver for MySQL but have no idea how to.
I have a jquery script that collects data from different sites and saves it
I want to create a test table that is empty. Using the Example from
I want to create a PDO class for handling data base connections. Here is

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.