Jump to content

SELECT * FROM TWO TABLES


scrubbicus

Recommended Posts

Not only it's slow, it's totally senseless.

 

Probably you should use UNION

That only works if you're selecting the same number of columns from each table, which is not always the case.

Of course, but that's a formal point, and you can find a workaround to it.

But if your tables are not related, surely you can't join them. And this is a logic point, no workaround.

Link to comment
Share on other sites

So I should use UNION or JOIN  I'll look up those commands on the MySQL website and learn more about those.? Are those the only two ways I can do what I'm trying to do?

Well, are they "related" to each other or just "duplicates"?

Link to comment
Share on other sites

These two tables are not related to each other.

 

One is where all the articles are posted and the other is where I store all my content information for the different pages. I just want to be able to SELECT ALL from each table preferably a different column name for both but I can definitely change the column name so that the 'content' column is the same for both. So I'd be selecting two different tables with a column that has the same name.

Link to comment
Share on other sites

I don't understand if you need all the columns in the tables or just one for each table.

In the second case you can do something like

 

SELECT column1 FROM table1

UNION all

SELECT column2 FROM table2

 

and you'll get all you want under the name 'column1'

Link to comment
Share on other sites

Hi

 

It would join every row together. Ie, say one table had rows with a column values 1, 2 and 3, while the other had values 7, 8 and 9, you would get returned 9 rows rather than 6, each with 2 columns giving 1,7 / 1,8 / 1,9 / 2,7 / 2,8 / 2,9 / 3,7 / 3,8 / 3,9.

 

As the number of rows on the originals tables increased the number of returned rows would go through the roof.

 

It can be useful if you want every combination of rows between 2 tables, but almost certainly not in this situation.

 

All the best

 

Keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.