answersLogoWhite

0


Best Answer

using aliases:

SELECT a.some_fields, b.other_fields

FROM table a, table b

WHERE a.foreign_key=b.primary_key;

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you join a table to itself in sql?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is join in sql?

join combine the two table to gv a resultant set


What does an SQL join combine?

A SQL join clause combines records from two or sometimes more than two tables in to a database. This creates a set that can be used as it is or can be saved as a table.


What is Outer Join SQL used for according to Wikipedia?

Outer Join in SQL is used to retrieve all records from one table and only matching records from another table. It helps to retrieve data from related tables even if there are no matching records in one of the tables.


Can you join a table to itself?

Yes. In MySQL you can join a table to itself. You must use different alias name for each instance.


How many types of SQL JOINS?

Joins refer to the combination of related records to form a relation . There are six types of joins in database . Types of joins are cross join, natural join , right join , left join ,Inner join, Outer join.INNER JOINOUTER JOINLEFT JOINRIGHT JOINNATURAL JOINCROSS JOINIn special cases a table can join to itself (SELF JOIN)


How do you find maximum in SQL without using MAX function?

Using a left join of: SELECT a.number FROM table a, table b WHERE a.number < b.number where right table.number is null


What is hash table in sql?

temp table


What is the name of two DDL operations in SQL?

Some of the operations performed in DDL in sql are creation of table,alteration of table,truncate a table, drop a table


What is the most common type of join in SQL?

Inner Join


Definition of cross join in sql server?

Cross Join is jsut another Join


What does the term sql outer join mean?

SQL is a special language for making queries to databases. An outer join is a special form of joining two tables within the database, when a SELECT query is made. In the outcome of the query you will find all selected entries from the so called "left table" (the table that was target of the select query) and only those entries from the "right table" (the one that is joined with the other) that fit a specified joining condition.


What are the differences between SQL left join right join and full join?

All three join operations work in a similar manner, with the difference being the rows that are returned. A left join and right join are also commonly called "semi-joins." Both operate in the same manner, with the difference being which table is the primary table. In a left join, all rows on the left-hand table that meet the criteria are returned, even if there is no matching right-hand table data for that row. A right join is the complementary version of a left join; all rows on the right-hand table are returned, even if there is no left-hand table data. A full join returns all matching rows, even if there is no data on either the left-hand table or the right-hand table.