473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to show five tables in same code

Hi!

Sorry for my bad english in advance...
So, I have five tables (rpg_swords, rpg_armors, rpg_sheilds, rpg_users and rpg_potions) and I have that code:

<code>SELECT nume, item_code, iconita
FROM rpg_rpg_licori, rpg_rpg_users
WHERE item_code
IN (2,3,4,5,6,7,8,9,10,11,12)
GROUP BY item_code</code>

// That array (2,3,4,...) is just an exemple

Now, i want to create a code where result same thing but with the rest of the tables in the same code.

Sorry, I`m newbie in sql. I searched and probably I found but i don`t know how to proceed.
Sep 11 '14 #1

✓ answered by emailhosting

Hello ujoehero,

If you would like to fetch related datas from multiple tables in a single query. You may use the JOIN syntax. See the following case:

Let say we have:
table_one with the following columns/fields:
  • item_id
  • item_name
  • item_desc

table_two with the following columns/fields:
  • item_id
  • column_one
  • column_two

table_three with the following columns/fields:
  • item_id
  • column_three
  • column_four

Here is the example query you can use to fetch relative records from multiple tables using JOIN syntax.

Expand|Select|Wrap|Line Numbers
  1. SELECT table_one.item_id, table_one.item_name, table_one.item_desc, table_two.column_one, table_two.column_two, table_three.column_three, table_three.column_four FROM table_one LEFT JOIN table_two ON table_two.item_id = table_one.item_id LEFT JOIN table_three ON table_three.item_id = table_one.item_id WHERE table_one.item_id IN (2,3,4,5,6,7,8,9,10,11,12);
Hope this helps you.




------------------------

2 1219
Hello ujoehero,

If you would like to fetch related datas from multiple tables in a single query. You may use the JOIN syntax. See the following case:

Let say we have:
table_one with the following columns/fields:
  • item_id
  • item_name
  • item_desc

table_two with the following columns/fields:
  • item_id
  • column_one
  • column_two

table_three with the following columns/fields:
  • item_id
  • column_three
  • column_four

Here is the example query you can use to fetch relative records from multiple tables using JOIN syntax.

Expand|Select|Wrap|Line Numbers
  1. SELECT table_one.item_id, table_one.item_name, table_one.item_desc, table_two.column_one, table_two.column_two, table_three.column_three, table_three.column_four FROM table_one LEFT JOIN table_two ON table_two.item_id = table_one.item_id LEFT JOIN table_three ON table_three.item_id = table_one.item_id WHERE table_one.item_id IN (2,3,4,5,6,7,8,9,10,11,12);
Hope this helps you.




------------------------
Sep 17 '14 #2
Thank you! I found solution in an old book of sql/mysql, but I thank you! If I can reward you somehow, just say. :) You are the only guy who respond on that question in one week.
Sep 21 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file...
4
by: roni | last post by:
hi. is there a tool that compare 2 vs.net projects and show the differences in code ? (in text..) such tool will help me alot to see changes i made between backups for example. have a...
4
by: Dixie | last post by:
I wish to be able to do some things to tables in code. 1. Add a field and its properties. 2. Alter the properties of an existing field in a table. 3. Append some extra entries onto the bottom of...
0
by: San Diego Guy | last post by:
Hi all! I'm working with a SDK provided for some X10 software I have. If I use the code in an ASP page, nothing happens.. no error, just nothing. I haven't had a problem with ASP in the past on...
2
by: emaileric | last post by:
Hi all, I am looking for a way to create two different forms, with different look and feel. However, they would both have the same set of controls, and reference the same code behind page. I...
1
by: Stefan van Roosmalen | last post by:
Hi there, Is there a way to list the TEMPORATY tables? I have tried SHOW TABLES, but this command only list the regular tables. Thank you very much for your answer. Regards, Stefan.
1
by: mimenko | last post by:
Hello, I'd want to show and hide the same icons (pictures) on a web page that contains several icons. Some are identical, some are different (for ex : 3 items "A", 4 items "B", 2 items "C"). Is...
0
by: Juan Zamudio | last post by:
Hi, i asked this question in the component services group but appears to be dead, so i hope is ok to ask the question here, Is possible to use the same DLL for a .net application and for COM+?....
2
by: rathour | last post by:
<?php session_start(); require_once('db.php'); include('functions.php'); $user = get_username ( $_SESSION ); //if ( $_SESSION ): checkLogin ( '1 2' ); ?>
8
by: brucedodds | last post by:
I've inherited an A2003 application with linked SQL Server 2000 tables in the back end, using the Microsoft SQL Server ODBC driver. We've set up a test SQL Server database. I'd like to automate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.