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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:06:54+00:00 2026-05-31T06:06:54+00:00

I have a database with 2 tables I wish to pull data from both

  • 0

I have a database with 2 tables I wish to pull data from both and display it in an html table. When I execute the below select statement I seem to get everything but the auto_increment column “id”

>mysql connection strings here.

$query = "SELECT Hotels.*,surfcup_Rates.*
          FROM Hotels 
               LEFT JOIN surfcup_Rates
               ON Hotels.id=surfcup_Rates.hotelID";

Then I use load the query into $result.
Later I load it into mysql_fetch_array and loop it into an html table.

while ($row = mysql_fetch_array($result)) {
    echo "</td><td>";
    echo '<a href="DeleteHotelRecord.php?id="['.$row['id'].']">Delete</a>';
    echo "</td><td>";
    echo $row['id'];
    echo "</td><td>";
    echo $row['preferred'];
>and so on...........

Everything works: the join, the select statement and data loads into the table
perfectly. All except the id column from the first table. I wish to use the id to allow the user to delete a record. The user will be adding data to the tables from a password protected “back-end” for data entry.

Is there something wrong with my select statement? Or am I missing something. Any help will be greatly appreciated.
Thank You,
Dave.

  • 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-31T06:06:56+00:00Added an answer on May 31, 2026 at 6:06 am

    Does the surfcup_Rates table also have a field called id? If so, mySQL won’t know whatid to use, hotel or surfcup_Rates.

    In this case you have a couple of options,

    1. changing the table structure, but do so at your own risk as other things could break
    2. use an alias (best method)

    DISCLAIMER

    I have never used the following method in PHP myself, I have seen it in SAP and Zimbra, as this isn’t a discussion forum on these aspects, instead of a debate I thought I would put a disclaimer that it may not work but as mentioned above and in my comment below I have seen it work

    1. call hotels.id

    I hope this helps

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

Sidebar

Related Questions

I used to select data from mysql database by joining tables using PHP and
I have database with many tables. In the first table, I have a field
I have a database two tables and a linking table that I need a
I have a database with two tables ( Table1 and Table2 ). They both
I have an XML structure like the following: <tables> <table name=tableName1> <row ID=34 col1=data
i'm trying to migrate some data from two tables in an OLD database, to
I wish to create an external table in an Oracle database, retrieving its data
I have designed database tables (normalised, on an MS SQL server) and created a
I have two database tables with the following structure: actions: action_id int(11) primary key
I have 3 database tables, all of them have the same 5 columns. They

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.