Hi i need your help on MS Access Database. I have two tables,tblExpense with three Columns(ExpenseID,ExpenseDate,Status) And tblExpenseDetails(ExpenseID,RefNo,Amount,Purpose).
Which Select Statement should i use if i want to get the Status from tblexpense using the RefNo from tblExpenseDetails?
{SELECT tblexpenseDetails.RefNo,tblexpense.Status,tblexpenses.ExpenseDate FROM tblExpense INNER JOIN tblexpenseDeatils ON tblexpensedetails.ExpenseID=tblexpenses.ExpenseID WHERE tblexpenseDetails.RefNo=?;
Used That and it worked any other ideas are still welcome.
Related
Im trying to DISPLAY all customer name and their phone no under the Agent named Santakumar which have AGENT_CODE = A010.
the customers data have different table and agents data have also in the different table. the only thing that connect to them is AGENT_CODE.
I try using this QUERY but nothing happens and give this error:
Error Code: 1052. Column 'AGENT_CODE' in where clause is ambiguous 0.000 sec
SELECT A.AGENT_NAME, C.CUST_NAME, C.PHONE_NO
FROM agents AS A
JOIN customer AS C ON A.AGENT_CODE = C.AGENT_CODE
WHERE AGENT_CODE = 'A010'
Im new to MYSql so im not really that skilled in this field.
Thank you for the help in advance.
Since AGENT_CODE exists in more than one table/alias, you have to specify to which one you are referring to in the where clause:
WHERE A.AGENT_CODE = 'A010'
I am totally new to MS Access, so please be kind if my requests might look nonsense.
I have a database with two tables: tblHerbs and tblSeasons.
Two fields in tblHerbs refer to tblSeasons and I don't know how to set the relation between these two tables, besides building a simple query that allows me to select everything from tblHerbs (and show it on a Report).
Any kind of help would be highly appreciated.
You need alias
select t.Season1, s1.name, t.Season2, s2.name
from ((tblHerbs t
inner join tblSeasons s1 on s1.name= t.Season1 )
inner join tblSeasons s2 on s2.name= t.Season2)
I am a complete newbie in sql... I am using w3s tutorial to learn some basic queries to help me at work. I'm trying to join two tables (order info about quantity, price and product ordered and the second one with client data - name, second name, phone number). My database is on Adminer 4.2.4. I wrote something like this (all the columns names are correct):
SELECT order_id.orders_products, quantity.orders_products, product_id.orders_products, firstname.orders_address, lastname.orders_address, phone.orders_address
FROM orders_products
INNER JOIN orders_address ON orders_address.order_id=orders_products.order_id;
but I'm still getting this error:
error in query (1054): unknown column 'order_id.orders_products' in field list
Thank you in advance for any help :)
Hope this will help
SELECT orders_products.order_id,
orders_products.quantity,
orders_products.product_id,
orders_address.firstname,
orders_address.lastname,
orders_address.phone
FROM orders_products
INNER JOIN orders_address ON orders_address.order_id=orders_products.order_id;
I´m trying to update a third table with the result of a select query - I know how to do this on mysql but access makes insane :)
I have the following statement:
UPDATE ceilings LEFT JOIN
(SELECT ceiling_number AS cc, Count(type=3) AS st FROM ceiling INNER JOIN materials ON ceiling.material_number = materials.id GROUP BY ceiling.ceiling_number) AS q
ON q.cc=ceilings.ceilingid SET ceilings.stairs = q.st;
but it does not update tables and when I want to execute the statement i get the error:
"Operation must use an updateable query"
Would be great if someone could help me with this.
Update queries won't work with several types of other queries, including things like Group by, Totals, CrossTabs, or queries with left or right joins (in combination with inner joins).
There are a couple of solutions around this problem depending on your comfort level with Access and VBA.
Create a temporary table first. Write the results of your query to the temporary table, then use the temporary table to update the results of your ceilings table.
Use VBA to create and store the values of the non-update-able query, then using recordsets, loop thru your records and update the values in your ceilings table.
(i want distinct in msaccess query)
i have two tables where my data is matching and repeating in datagridview im working on report plz help me
here is my simple join query
select Labortary.Test_Name,Labortary.Test_Charges,LabortaryTestRecord.[Total Amount]
from LabortaryTestRecord,Labortary
where LabortaryTestRecord.[PatientID]=Labortary.Patient_id
and LabortaryTestRecord.[PatientID]=34
You must add DISTINCT keyword:
SELECT DISTINCT Labortary.Test_Name,Labortary.Test_Charges,
LabortaryTestRecord.[Total Amount]
FROM LabortaryTestRecord,Labortary
WHERE LabortaryTestRecord.[PatientID]=Labortary.Patient_id
and LabortaryTestRecord.[PatientID]=34