SQL statement from two tables

SQL statement from two tables

I would like to know if it is possible, to select certain columns from one table, and another column from a second table, which would relate to a non imported column in the first table. I have to obtain this data from access, and do not know if this is possible with Access, or SQL in general.

How do I define table relations in a circular reference?


Is there a standard way to duplicate a row in a database table?
Assuming the following table structure:.
SQL: sum 3 columns when one column has a null value?
CREATE TABLE tbl_1 (     pk_1 int,     field_1 varchar(25),     field_2 varchar(25) );  CREATE TABLE tbl_2 (     pk_2 int,     fk_1 int,     field_3 varchar(25),     field_4 varchar(25) ); 
You could use the following:.
Teradata locks - How to know if a table is locked?
SELECT t1.field_1, t2.field_3 FROM tbl_1 t1 INNER JOIN tbl_2 t2 ON t1.pk_1 = t2.fk_1 WHERE t2.field_3 = "Some String" 
In regard to Bill's post, there are two ways to create JOIN's within SQL queries:.
SQL Server 2000 - How to find out what indexes are in use?
It is always recommended that you use the explicit JOIN syntax as implicit joins can present problems once the query becomes more complex.

How can I efficiently do a database massive update?
. For example, if you later add an explicit join to a query that already uses an implicit join with multiple tables referenced in the FROM clause, the first table referenced in the FROM clause will not be visible to the explicitly joined table..


What you are looking for are JOINs:. http://en.wikipedia.org/wiki/Join_(SQL). You need primary keys for the referenced data sets and foreign keys in the first table..


I'm not 100% sure I understand your question.. Is the following true:. Your first table is imported from somewhere else.

You are only importing some columns.

You want to build a query which references a column which you haven't imported.. If this is true, it's just not possible.

As far as the Access query engine in concerned the non-imported columns don't exist.. Why not just import them as well?.


But primary keys make the query more efficient.

88 out of 100 based on 78 user ratings 928 reviews