N.K.Shaw
|
Posted: 02/01/2002, 4:38 AM |
|
Sir,
I have a problem in writing a SQL for the following situation :
I have a table USER containd the following fields :
Login_name
Password
User_level
Deptt_id (Number)
I have a second table COMPLAINT contains the following fields :
complaint_id
Deptt_id
Subject
Details
date_of_complaint
I have used the Login_name and Password to assess the desired complaint grid page.
I want to display only those records to the user whose Deptt_id(of the USER Table)
is Equal to the Deptt_id (of the COMPLAINT Table)
Please Help Me.
Thanks in Advance.
N.K.Shaw
|
|
|
Nicole
|
Posted: 02/01/2002, 5:12 AM |
|
Hello,
create custom sql, test it in query analyzer. In CC create Grid form and paste custom sql on Form->Properties->SQL tab.
|
|
|
N.K.Shaw
|
Posted: 02/01/2002, 5:19 AM |
|
Sir,
I am a new user Please help me in writing the SQL.
Please give the required SQL.
Thanks in Advance.
N.K.Shaw
|
|
|
Tom
|
Posted: 02/01/2002, 5:31 AM |
|
SELECT u.login_name, u.password, u.user_level, u.deptt_id, c.complaint_id, c.subject, c.details, c.date_of_complaint
FROM user AS u, complaint as c
WHERE u.deptt_id = c.deptt_id
The where clause contains the 'join' of the tables
The tables are 'aliased' to u and c and each field is then denoted by the alias so you know which table has which field.
You can take away what ever fields you want from the select statment.
If you have rights to the database, I find it easier to create a 'view' or a query in the database to crunch/format your data and then just select from that view/query.
fyi
|
|
|
|