Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
List the name of all clients who have viewed a property based on the UML graph
SELECT [C-NAME]
FROM [CLIENT]
JOIN [PROPERTY]
ON CLIENT.CLIENTID = PROPERTY.PROPERTYID
If I've understood that UML model you can't, View-Appointment needs ClientID and PropertyID adding.
Then you can do, to give all clients that have an appointment (obviously adding a WHERE on the date column will give you future/past appointments):
select [C-Name] from [Client] inner join [View-Appointment] on Client.ClientID = View-Appointment.ClientID;
If you want property details in the query then you need another inner join:
inner join Property on Property.PropertyID = View-Appointment.PropertyID
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I need help regarding SQL joins, i am trying join two tables as shown in below images
I guess you can try the below query to get the desired result -
SELECT CASE WHEN CT.partner2 IS NULL
THEN C.partner_id
ELSE CT.partner1
END Partner1,
CT.partner2,
C.Type,
C.Company_name,
C.First_name,
CT.city,
CT.Phone,
CT.Email
FROM CUSTOMER C
LEFT JOIN CONTACTS CT ON C.partner_id = CT.partner2
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Permission to ask, why is this the error? I try
select user_idea.idea_id,user_idea.title, idea_events.events, idea_categories.category_name AS category
from user_idea
LEFT join idea_events
on user_idea.idea_id=idea_events.idea_id
LEFT JOIN idea_categories
ON user_idea.idea_categories=idea_categories.category_id;
The result is sqliteonline like this:
I want to combine Dewasa and Anak events because of the same idea. For category why is the result NULL for values 1;2 not read in the idea_category table which should be Mudah; Sedang.
For table:
Output expected:
select user_idea.idea_id,user_idea.title,
(SELECT GROUP_CONCAT(events,';') FROM idea_events Where user_idea.idea_id=idea_events.idea_id) as events,
(SELECT GROUP_CONCAT(category_name ,';') FROM idea_categories Where user_idea.idea_categories=idea_categories.category_id) AS category
from user_idea;
1:2 idea_categories in user_idea is not considered as relevant to join so when joined it cannot find the data in other table here so data is null
reminder
before doing join just analyse the data anomalies like not having common data and properly formatted
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
select *
from aBook as ab left join
org as org on ab.idorg = org.id left join
class as ar on ab.idclass = ar.name
where dateofstatus <='2020/01/17' and dateofstatus >= '2019/12/31'
order by orgname;
I need to catch name column from table class, my connection between tables aBook and class is the same id column.
It is entirely unclear what the problem might be. However, this JOIN condition is quite suspicious:
on ab.idclass = ar.name
Normally, a name is a string. And an id is a number. If the naming conventions matches the expected types, then this would cause the error referred to in the title.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have to find riskunits.descriptions that are missing on policies.
I can match riskunitid on policyid - but how do I find a policy that does not have a riskunit.description? I am new to SQL
Not knowing your exact table structure, we'll have to make do with some pseudo code:
select *
from policy p
where not exists (
select *
from riskunit r
where r.policyid = p.policyid
)
This will find policies with no riskunit record. If you expect there will always be a riskunit record, but the description may be null or an empty string, go with this instead:
select *
from policy p
join riskunit r
on r.policyid = p.policyid
where (r.description is null or r.description = '')
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How can I write a SQL query that will replace the "ComputerID" and "PartID" with the "UnitNumber". The ComputerID's and PartID's are in the same column under InventoryID. The InventoryID's are unique but the UnitNumber (sticker label/name) doesn't have this requirement.
Here are the tables and how they relate.
Let's call your tables Object and Inventory
If you use a couple of joins then this should work:
select o.ObjectID as ObjectID, a.UnitNumber as Computer, b.UnitNumber as Part,
o.InputID from Object o
join Inventory a on a.InventoryID=o.CombputerID
join Inventory b on b.InventoryID=o.PartID