https://antibiotiqueaugmentin.com/surdosage-augmentin-bebe/
× Welcome to the ToolsJX forum!


MySQL: Create View from different tables

  • ARIALDO
  • ARIALDO's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 2 months ago #3075

I've bought your whole package and I like it very much. However: I read your short instruction about merging different tables in a new table/view. I always get syntax errors. The solution to my problem is probably quite simple, but I just can't do it. Please help.

I want to generate a new table/view for articles (jos_content).

Jos_content contains the columns id / introtext / catid / created by

I want to replace the column "catid" with the title of the category (jos_categories,column "title").
I want to replace the column created_by" with the name of the user (jos_users, column "name".)

It is that simple! But I don't manage it.

The final table should look like

article name / category name / name of the author

Thank you for your help!

Ari

Please Log in or Create an account to join the conversation.

More
9 years 2 months ago #3081

Hi, try the following. Do not forget to replace the table prefix with yours.

CREATE VIEW my_view as
SELECT cj2l8_content.*, cj2l8_users.name as user, cj2l8_categories.title as category FROM cj2l8_content
INNER JOIN cj2l8_users on cj2l8_users.id=cj2l8_content.created_by
INNER JOIN cj2l8_categories on cj2l8_categories.id = cj2l8_content.catid

Please Log in or Create an account to join the conversation.

Moderators: tomaz
Time to create page: 0.146 seconds

Contact Us

Contact us on Discord

Contact us on Facebook