Wie kann ich in SQL diese abfrage stellen?
SELECT
s2.id,
s2.name,
substring(s2.name, 16, 5) AS Standortgruppe
FROM
setnames AS s2
WHERE
s2.name LIKE '%Standortgruppe%'
AND (
SELECT
Standortgruppe
FROM
setnames AS s2
INNER JOIN cashpoints AS cp ON Standortgruppe = cp.location
)
also ich möchte dass der Wert der bei Standortgruppe kommt, nochmal verglichen wird mit den Werten aus cashpoints, location.
2 Antworten
SELECT s2.id,
s2.name,
SUBSTRING(s2.name, 16, 5) AS Standortgruppe
FROM setnames s2
WHERE s2.name LIKE '%Standortgruppe%'
AND EXISTS (SELECT 1
FROM cashpoints cp
WHERE s2.Standortgruppe = cp.location);
Woher ich das weiß:Studium / Ausbildung
select s2.id, s2.name, substring(s2.name, 16, 5) as Standortgruppe
from setnames s2
join cashpoints cp on cp.location = substring(s2.name, 16, 5)
where s2.namelike
'%Standortgruppe%'