--Que-5) Select CTM_NBR,LIST_CO DE,ADR_CDE,ADR_ FLAG
--From table A,B,C,D by linking the tables where
--the LIST_CODE=18.
TABLE A Has Column CTM_NBR
TABLE B Has Columns CTM_NBR , ADR_CDE , ADR_FLAG
TABLE C Has Columns LIST_CODE , CTM_NBR, ADR_CDE
TABLE d Has Column LIST_CODE select CTM_NBR,LIST_CO DE,ADR_CDE,ADR_ FLAG from A,B,C,D
where A.CTM_NBR = B.CTM_NBR
AND
B.CTM_NBR = C.CTM_NBR
AND
C.LIST_CODE=D.L IST_CODE
AND
D.LIST_CODE=18
I have tried the aboce Query but its not working,Plz reply asap,Its Urgent.
3 1382 Delerna 1,134
Recognized Expert Top Contributor
The types of joins you use depends on the data you have in your tables
But it should look something like this -
select CTM_NBR,LIST_CODE,ADR_CDE,ADR_FLAG
-
from A
-
left join B on A.CTM_NBR = B.CTM_NBR
-
left join C on A.CTM_NBR = C.CTM_NBR
-
and B.CTM_NBR=C.CTM_NBR
-
and B.ADR_CDE=C.ADR_CDE
-
left join D on C.LIST_CODE=D.LIST_CODE
-
where D.LIST_CODE=18
-
NOTE
====
1) Join will only return records where there is a match in both tables
2) Left Join will return every record from the first table
regardless of whether there is a match in the second table
There are other types of joins. Check the help files
Actually delerna it was a interview Question of company I have faced...dats that I have also no idea abt the tables,So I Didn't know where to use JOIN oR LEFT JOIN.
Hi Mansi,
I Think the query
select CTM_NBR,LIST_CO DE,ADR_CDE,ADR_ FLAG from A,B,C,D
where A.CTM_NBR = B.CTM_NBR
AND
B.CTM_NBR = C.CTM_NBR
AND
C.LIST_CODE=D.L IST_CODE
AND
D.LIST_CODE=18
is perfectly fine except you should give the alias to each table n then use alias to access their respective column. However can u pls tell me is query giving any sysntax error or not returning any data...??
It it is not returning any data try to use LTrim(RTrim(Upp er(C.LIST_CODE) ))=LTrim(RTrim( Upper(D.LIST_CO DE))) or
LTrim(RTrim(Low er(C.LIST_CODE) ))=LTrim(RTrim( Lower(D.LIST_CO DE)))
this may be the solution.
However the solution given by Delerna is also fine.
Regards,
Mukta
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: DaveF |
last post by:
How can I retrieve display_names
Dim custDS As DataSet = New DataSet
Dim mySQL, mySQL2, mySQL3 As String
|
by: Torben Jensen |
last post by:
Hi,
Does anyone have experience in retrieveing useraccount information like eg.
name, lastname, phonenumber, adress etc from Active Directory from an
asp.net application?
Perhaps standard components have already been developped to accomplish this
task?
Should I query the AD directly each time a request is made or should I
|
by: Captain Nemo |
last post by:
Hi
I'm working on an ASP project where the clients want to be able to
effectively perform SELECT queries joining tables from two different
databases (located on the same SQL-Server).
Does this involve creating virtual tables that link to another database, or
am I completely on the wrong track?
Any hints as to where I might find more information (buzz-words, etc.) would
|
by: kmanjani |
last post by:
hi,
i have to retrieve data from 4 tables at a time...can anyone guide me in wrting a query for the same..
Ex:-
i have four fields f1,f2,f3,f4 which i need to retrieve from four tables t1,t2,t3,t4 where f4='A'
can anyone help me in this regd?
|
by: kev |
last post by:
Hi all,
I have created a database for equipments. I have a form to register the
equipment meaning filling in all the particulars (ID, serial, type,
location etc). I have two buttons at the end of the form which is
submit and cancel. After i have clicked submit, the information is
stored directly into my corresponding database table. My problem here
is i need to retrieve back the information submitted to display all the
data that the...
| |
by: mdallison |
last post by:
How can I join two tables I have and keep the columns independently distinct.
For example, say i have the folowing tables:
table1:
station_id sequence
-------------------------------
1 ---------- 1
1 ---------- 2
|
by: trint |
last post by:
How can I retrieve all of the data from a datagridview?
Any help is appreciated.
Thanks,
Trint
|
by: tigger |
last post by:
Hi there,
I'm having problems retrieving data from Access database using Visual basic 2005. My database is called Actual_Database and it has a few tables. One of them is called Threshold Database. I'm trying to retrieve data from Threshold Database. In that table, it has columns of AC250L, AC250R, BC250L, BC250R, AC500L etc.. When i select a name from the combo box, and click presentButton, it will show a smile if the values from...
|
by: sudhashekhar30 |
last post by:
i have to retrieve all columns of four table except common field(which is primary key in 1 table and foreign key in other table) will come only once from main table where condition is given by user. eg
table1- id(pk), name sex
table2- id(fk), address,contactno
table3- salary, pf,other,id(fk)
table4-id(fk), language,department
now i have to pick --id,name, sex,address,contactno,salary,pf, other,language,department-- where id= given by...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |