Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

...I enjoy spending time on it for personal growth (I learn from the questions I don't answer, and I reinforce/stay sharp on the topics I do answer), and to give back to humanity at large...

Geography

Where in the world do Tek-Tips members come from?
simonsoot (TechnicalUser)
13 Jun 12 19:45
I hope this is placed in the correct forum...I am a novice to the forum and SQL, but using Access for what I thought would be a simple query:

I have two tables, and I have written the below and is successful:

SELECT DISTINCT dbo.imitmidx_sql.item_no, dbo.imitmidx_sql.item_desc_1, dbo.imitmidx_sql.item_desc_2, dbo.bmprdstr_sql.item_no AS Expr1
FROM dbo.imitmidx_sql INNER JOIN
dbo.bmprdstr_sql ON dbo.imitmidx_sql.item_no = dbo.bmprdstr_sql.comp_item_no
WHERE (dbo.imitmidx_sql.activity_cd = 'A') AND (dbo.imitmidx_sql.item_no LIKE 'F%') AND (NOT (dbo.imitmidx_sql.item_desc_1 LIKE 'M%')) AND (NOT (dbo.imitmidx_sql.item_desc_1 LIKE '%KIT%')) AND (NOT (dbo.imitmidx_sql.item_desc_1 LIKE '%PACK%')) AND (NOT (dbo.imitmidx_sql.item_desc_2 LIKE '%KIT%')) AND (NOT (dbo.imitmidx_sql.item_desc_2 LIKE '%PACK%')) AND (dbo.bmprdstr_sql.comp_item_no LIKE 'F%') AND (dbo.bmprdstr_sql.activity_fg = 'A')

the step I can not complete is to utilize the results of the query, and take the column of dbo.bmprdstr_sql.item_no and use that column to display dbo.imitmidx_sql.item_desc_1 and dbo.imitmidx_sql.item_desc_2

so if this is unclear, I have the results of the above query, but I want is to add two more columns that display the item description 1&2 but the data is from the second table.

I am sure this is fairly basic, but after many a Google searches, I have failed and any help is appreciated. thanks!

PHV (MIS)
13 Jun 12 20:45
Something like this ?
SELECT DISTINCT I1.item_no, I1.item_desc_1, I1.item_desc_2, B.item_no, I2.item_desc_1, I2.item_desc_2
FROM dbo.imitmidx_sql I1
INNER JOIN dbo.bmprdstr_sql B ON I1.item_no = B.comp_item_no
INNER JOIN dbo.imitmidx_sql I2 ON B.item_no = I2.item_no
WHERE I1.activity_cd = 'A' AND I1.item_no LIKE 'F%'
AND I1.item_desc_1 NOT LIKE 'M%' AND I1.item_desc_1 NOT LIKE '%KIT%' AND I1.item_desc_1 NOT LIKE '%PACK%'
AND I1.item_desc_2 NOT LIKE '%KIT%' AND I1.item_desc_2 NOT LIKE '%PACK%'
AND B.comp_item_no LIKE 'F%' AND B.activity_fg = 'A'

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

simonsoot (TechnicalUser)
14 Jun 12 9:13
PHV,

Thank you for your reply! After a better understanding if what the additional INNER JOIN did, I was able to alter and get what I want!

thank you very much!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close