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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:13:13+00:00 2026-06-11T05:13:13+00:00

I have a program that downloads information from and outside source and provides me

  • 0

I have a program that downloads information from and outside source and provides me with a page of sql for each query I have entered.Normally there are 3 – 6 queries associated with each title.
Each sql page loads a new table and all tables have the same columns. below are examples of the results for queries UsedCar and NewCar which is 2 of the 6 queries involved in the Title Automotive.

CREATE TABLE IF NOT EXISTS NewCar(Name char(255) DEFAULT NULL,
Phone char(255) DEFAULT NULL,
Address char(255) DEFAULT NULL,
Website char(255) DEFAULT NULL,
Email char(255) DEFAULT NULL,
Category char(255) DEFAULT NULL,
UNIQUE KEY Name (Name))
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

LOCK TABLES NewCar WRITE;
REPLACE INTO NewCar VALUES('whats it Auto','1-888-555-7327','63 Beech Hill Rd, Beechville, NS B1G 2R9','http://www.whatsit.com','','New Car Dealers');
REPLACE INTO NewCar VALUES('Hugh\'s Chev','888-555-6990','376 Main St, lower bohemia, NS B5G 2D6','','','New Car Dealer');
REPLACE INTO NewCar VALUES('Be It Motors Ltd','866-555-2771','90 Main St, Upper Bohemia, NS B9G 2K8','','','New Car Dealers');
UNLOCK TABLES;


CREATE TABLE IF NOT EXISTS UsedCar(Name char(255) DEFAULT NULL,
Phone char(255) DEFAULT NULL,
Address char(255) DEFAULT NULL,
Website char(255) DEFAULT NULL,
Email char(255) DEFAULT NULL,
Category char(255) DEFAULT NULL,
UNIQUE KEY Name (Name))
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

LOCK TABLES UsedCar WRITE;
REPLACE INTO UsedCar VALUES('whats it Auto','1-888-555-7327','63 Beech Hill Rd, Beechville, NS B1G 2R9','http://www.whatsit.com','','Used Car Dealers');
REPLACE INTO UsedCar VALUES('Hugh\'s Chev','888-555-6990','376 Main St, lower bohemia, NS B5G 2D6','','','Used Car Dealer');
REPLACE INTO UsedCar VALUES('Be It Motors Ltd','866-555-2771','90 Main St, Upper Bohemia, NS B9G 2K8','','','Used Car Dealers');
UNLOCK TABLES;

These are then loaded into my Database.

My problem is in trying to draw off this information into my webpage. I would like to create a link that shows unique information under Automotive excluding the Category. I can do this from one table but have not been able to do this for multiple table.
I have tried researching the problem and have tried selecting DISTINCT and UNIQUE. As well as doing table JOIN and UNION – I am sure it is probably something very stupid I am forgetting.

Below is the PHP I use to draw from a single table that has been modified to try to draw from 2 tables and returns “no records found”.

<?php
$result = mysql_query("SELECT DISTINCT Name FROM (SELECT * FROM UsedCar UNION    SELECT*FROM NewCar) ORDER BY name ASC");
if(mysql_num_rows($result) == 0){
echo("no records found");
} ELSE {
echo "<table border='0'; table id='address'>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Address</th>
<th>Website</th>
</tr>";

while($row = mysql_fetch_array($result))

  {
  echo "<tr>";
  echo "<td>" . $row['Name'] . "</td>";
  echo "<td>" . $row['Phone'] . "</td>";
  echo "<td>" . $row['Address'] . "</td>";
  echo '<td><a href="' . $row['Website'] . '" target="_self\">' . $row["Website"] . '</a></td>';
  echo "</tr>";

  }
echo "</table>";
}

?>

Sorry for long post..:)

  • 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-11T05:13:14+00:00Added an answer on June 11, 2026 at 5:13 am

    Part of the problem is your SQL syntax, you are missing the alias on the sub-select

    You query with no alias (see SQL Fiddle):

    SELECT DISTINCT Name 
    FROM 
    (
      SELECT * 
      FROM UsedCar 
      UNION    
      SELECT *
      FROM NewCar
    ) 
    ORDER BY name ASC
    

    With alias works (see SQL Fiddle)

    SELECT DISTINCT Name 
    FROM 
    (
      SELECT * 
      FROM UsedCar 
      UNION    
      SELECT *
      FROM NewCar
    ) x
    ORDER BY name ASC
    

    But if you only want the name then you don’t need the subquery (see SQL Fiddle):

    SELECT name 
    FROM UsedCar 
    UNION    
    SELECT name
    FROM NewCar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that downloads PCM data from a Web Server, which it
I have a program that downloads basic historical stock data from yahoo and puts
I have a program that downloads a binary file, from another PC. I also
I have a program that gets a JSON from the server using getJSON and
I have a program that reads from a file that grabs 4 bytes from
I have some code that downloads a file from the internet located here: http://www.amsat.org/amsat/ftp/keps/current/nasa.all
So I have this program that fetches a page using a short link (I
I have a command-line utility that gets quite a bit of downloads from my
I have a WiX installer that runs a program that downloads the latest version
I have a program that will get messages from a server and store them

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.