473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

SQL Query Help

2
Hi,

I have jobs, jobapprover table. Job submitter can be a approver for another job. i.e one to many relationship with these fields

JobID SubmitterEmail JobName
1 aaa@company.com job1
2 bbb@company.com job2
3 abc@company.com job3
4 cdc@company.com job4

2nd table jobapprover
JobAssignedid jobid approveremail
1 1 approver1@company.com
2 2 aaa@company.com
3 1 approver2@company.com
4 4 aaa@company.com

I want the result set i.e i will be passing email address
ex: aaa@company.com email i want the record he submitted and the job assigned to him in a single query
JobID JobName Email
1 job1 aaa@company.com
2 job2 aaa@company.com
4 job4 aaa@company.com
Mar 14 '08 #1
2 909
Delerna
1,134 Expert 1GB
not sure if this is what you are after
but you could call a stored procedure like this

Expand|Select|Wrap|Line Numbers
  1.      exec prListJobs 'aaa@company.com'
  2.  
where the stored procedure is something like this
Expand|Select|Wrap|Line Numbers
  1. CREATE PROC prListJobs @UserAddress varchar(100)
  2. as
  3.     SELECT jobID,JobName,SubmitterEmail as Email
  4.     FROM tblSubmittedJobs
  5.     WHERE SubmitterEmail = @UserAddress 
  6.     UNION ALL
  7.     SELECT a.jobID,a.JobName,b.ApproverEmail as Email
  8.     FROM tblSubmittedJobs a
  9.     LEFT JOIN tblApprovedJobs b on a.jobID=b.jobID
  10.     WHERE ApproverEmail=@UserAddress 
  11. GO
  12.  
Mar 14 '08 #2
casstd
2
Hi,

Thank you for your reply.
I have given example. i have more columns to select from Job tables than job assigned table.

Thank you.




not sure if this is what you are after
but you could call a stored procedure like this

Expand|Select|Wrap|Line Numbers
  1.      exec prListJobs 'aaa@company.com'
  2.  
where the stored procedure is something like this
Expand|Select|Wrap|Line Numbers
  1. CREATE PROC prListJobs @UserAddress varchar(100)
  2. as
  3.     SELECT jobID,JobName,SubmitterEmail as Email
  4.     FROM tblSubmittedJobs
  5.     WHERE SubmitterEmail = @UserAddress 
  6.     UNION ALL
  7.     SELECT a.jobID,a.JobName,b.ApproverEmail as Email
  8.     FROM tblSubmittedJobs a
  9.     LEFT JOIN tblApprovedJobs b on a.jobID=b.jobID
  10.     WHERE ApproverEmail=@UserAddress 
  11. GO
  12.  
Mar 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
7
by: Simon Bailey | last post by:
How do you created a query in VB? I have a button on a form that signifies a certain computer in a computer suite. On clicking on this button i would like to create a query searching for all...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
5
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the...
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
4
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.