Solved

VB.net SQL See all in one table

Posted on 2014-09-26
3
176 Views
Last Modified: 2014-09-26
I am building the following SQL statement to see everything in my BANK table that has the same [LINK ID] as
my Payments table and everything in my Payments table (Linked and not linked). I am not seeing some items
in my Payments table. Shouldn't I see everything from that side


            Dim sSQL As String
            sSQL = "Select Bank.*, Payments.*"
            sSQL = sSQL & " From Bank Right Join Payments on Bank.[LINK ID] = Payments.[LINK ID]"
0
Comment
Question by:murbro
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40345637
Select Bank.*, Payments.*"

will/would very likely result in "duplicate" column names in the result
as consequence, some db drivers will either
* raise an error
* rename the columns,
* skip the columns
* fill the columns with the same data as previous column

the only way to solve this out is to write a SQL that avoids duplicate column names, hence not using table.* in your select
the "workaround" I usually use is that I do this inside a view on the database side, and the application then does the select * from view_name, this way I could add new columns to the tables/views without breaking the application code and without having to deploy a new exe ...
0
 
LVL 3

Expert Comment

by:PrisonBroken
ID: 40345671
I always work with a left join but yes that looks like it should work.

Which specific rows are not showing up, is there a commonality in those that might help figure out why they are not returned?
0
 

Author Closing Comment

by:murbro
ID: 40345681
Thanks
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now