0

I'm looking to join tableA with tableB to get a series of resulting data.

I need the JOIN with tableA and tableB to ensure I get the correct values from tableA, however, I don't want any of the values from tableB when I fetch the results.

I appreciate that I can do the following:

SELECT a.col1, a.col2, a.col3 FROM tableA AS a etc

I'm looking for a neater way, maybe with some cool new keyword I haven't come across before? (Here's hoping).

Thank you in advance.

Alex
  • 8,043
  • 9
  • 42
  • 56
  • Select * is not necessarily a [good way](http://stackoverflow.com/questions/65512/which-is-faster-best-select-or-select-column1-colum2-column3-etc) – Tim Lehner Mar 22 '12 at 20:53
  • @Tim Interesting post. Largely unimportant for my project at this stage though. – Alex Mar 22 '12 at 21:10

3 Answers3

2

you can either name out all of your fields:

SELECT a.col1, a.col2, a.col3... 
FROM tableA a
JOIN tableB b
    on a.id = b.id 

or just use you table alias a.*

SELECT a.* 
FROM tableA a
JOIN tableB b
    on a.id = b.id
Taryn
  • 234,956
  • 54
  • 359
  • 399
1

If you want all columns from table a, just use a.*:

SELECT a.* FROM tableA AS a etc
alexn
  • 55,635
  • 14
  • 110
  • 143
1
select a.* FROM tableA a JOIN tableB b ON a.b_id = b.id;
Ray
  • 38,399
  • 19
  • 91
  • 131