get a list of record based only the specific values from table (1 Viewer)

akika

Registered User.
Local time
Today, 08:23
Joined
Aug 7, 2018
Messages
102
hi,
i have 2 tables..
tbl_sales fields (ID, Date, Empl_name, type, status, category, comments)
contains full list of all details that being sold per date.

tbl_specific_empl fields(ID, mainEmpl_name) contains only 5 specific employee name using it as list of values.

tables are independent..(attached data & tbls)

with this query getting error - at most one record to be returned by this subquery..

SELECT tbl_sales.[date], tbl_sales.[Empl_name], tbl_sales.[Type],
tbl_sales.[status], tbl_sales.[category], tbl_sales.[comments]
FROM [tbl_sales], tbl_specific_empl
WHERE tbl_sales.empl_name = (select mainEmpl_name from tbl_specific_empl where mainEmpl_name is not null);
;



how to do that i get a list of record based only the specific values in tbl_specific_empl. via query and any code to add to the button in a continuous form 'btn_specificempl'
 

Attachments

  • data.xlsx
    8.8 KB · Views: 96
Last edited:

June7

AWF VIP
Local time
Today, 07:23
Joined
Mar 9, 2014
Messages
5,425
Try using IN instead of =.

Are you saving employee name or ID in tbl_Sales? Should be ID.
 

plog

Banishment Pending
Local time
Today, 10:23
Joined
May 11, 2011
Messages
11,613
how to do that i get a list of record based only the specific values in tbl_specific_empl. via query and any code to add to the button in a continuous form 'btn_specificempl'

I don't understand what you are asking. I advise you demonstrate your issue with data.

You have posted some sample data. So, using that, tell me what data you expect your query to return.
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:23
Joined
Jan 23, 2006
Messages
15,364
@akika,

Why do you consider these tables to be independent?
 

akika

Registered User.
Local time
Today, 08:23
Joined
Aug 7, 2018
Messages
102
i want the highlighted data to be displayed.
Will post a db sample
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:23
Joined
Feb 19, 2002
Messages
42,986
Use a join. There is no reason to use a sub-select.

SELECT tbl_sales.[date], tbl_sales.[Empl_name], tbl_sales.[Type],
tbl_sales.[status], tbl_sales.[category], tbl_sales.[comments]
FROM [tbl_sales] Inner Join tbl_specific_empl
ON tbl_sales.empl_name = tbl_specific_empl.mainempl_name;
 

Users who are viewing this thread

Top Bottom