select different column from table A according to table B

select different column from table A according to table B

Post by Shen » Tue, 01 May 2001 15:52:56



do a inner join on both tables.


how to select different column from table A according to table B

select (select formular from TableB where comid='pg01')
from tableA where markupid=1

the tableA column will be decided by tableB select result.  How to do that?

 
 
 

select different column from table A according to table B

Post by BP Margoli » Tue, 01 May 2001 23:36:40


Stephen,

When requesting assistance with SQL, please post (simplified) table schemas
(CREATE TABLEs), sample data (INSERTs) and the results you want using the
sample data.

Narratives are frequently ambiguous.

My best guess at what you want is something like:

create table TableA
(
 a1 int NOT NULL primary key,
 a2 char (1)
)

create table TableB
(
 b1 int NOT NULL primary key,
 b2 char (1)
)
go

insert into TableA values (1, 'a')
insert into TableA values (2, 'b')

insert into TableB values (1, 'c')
insert into TableB values (2, 'd')

select *
from TableA as a
join TableB as b
  on (a.a1 = b.b1)

If this is not want you are looking for, then please post as requested
above.

--------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


how to select different column from table A according to table B

select (select formular from TableB where comid='pg01')
from tableA where markupid=1

the tableA column will be decided by tableB select result.  How to do that?

 
 
 

1. R: select different column from table A according to table B

you can also try this:
select tab_union.value from
(select field1 as value,'field1' as field from tab1
union
select field2 as value,'field2' as field from tab1
union
select field3 as value,'field3' as field from tab1
) tab_union
inner join tabB on tab_union.field = tabB.field
where tabB.comid='pg01'

but i don't know if it is the optimal solution ....


how to select different column from table A according to table B

select (select formular from TableB where comid='pg01')
from tableA where markupid=1

the tableA column will be decided by tableB select result.  How to do that?

2. Datareports and boolean-datafields

3. how to establish referntial integraty of a column with two different columns of different tables

4. Where's the paradigms? (was: C++ <> OOP?)

5. Clone a table to a new table on different db/server wth only two columns

6. Find Diagram for a Table?

7. Clone table to a new table on different db and server with only two columns

8. Low volume deadlocks?

9. Selecting the first 6 columns of a table by column order/ column id

10. Selecting all columns, but in a different order in SELECT statement

11. inserting multible columns from one table into a single column in another table

12. HELP: users granted SELECT ANY TABLE can't select any table

13. Columns in different table.