Place-Calendar

D-97993 Creglingen + 20 km    

validator   x   p591b_mini | remso's gast | 0.021 sec


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Termine ORT und Umkreis lesen
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT
 SQL_CALC_FOUND_ROWS
 trm1.*
,trm1.id                        TID
,DATE_FORMAT(trm1.tag,'%w')     wotag
,DATE_FORMAT(trm1.tag_bis,'%w') wotag_bis
,IF ( trm1.festival_kz = '1', trm1.id, IF( trm1.gastgebende_TID IS NOT NULL AND trm1.gastgebende_TID > '0', gastgebende_TID +1, '99999' ) )  festival_id # 2017-05-27
,IF ( trm1.festival_kz = '1', '0', '1' )  festival_sort  # Festivals vor Teilnehmer

#,trm1.mp3_titel
#,trm1.mp3_url
,trm1.html_position_lang
,trm1.html_position_kurz

,ort1.land_kz
,ort1.plz
,ort1.name        ort_name
,ort1.geo_breite  ort_geo_breite
,ort1.geo_laenge  ort_geo_laenge

,ROUND( 6366.0 * ACOS( SIN(0.86312640163502) *SIN(RADIANS(ort1.geo_breite)) +COS(0.86312640163502) *COS(RADIANS(ort1.geo_breite)) *COS(RADIANS(ort1.geo_laenge) -0.17570927711528 ))) distanz_km
,adr1.id      VIP
,adr1.firma1
,trp1.id          TRP
,trp1.bild_url    trp_bild_url  -- fuer icon_webcam
,trp1.bild_titel  trp_bild_titel
,typ1.id          TYP
,typ1.name        typ_name
FROM        (bia_termine trm1
            ,bia_orte ort1 )

LEFT JOIN   bia_adressen adr1
ON          adr1.id = trm1.adress_id

LEFT JOIN   bia_treffpunkte trp1
ON          trp1.id = trm1.treffpunkt_id

LEFT JOIN   bia_termintypen typ1
ON          typ1.id = trm1.typ_id

WHERE       trm1.owner_id = '1'
AND         ort1.id = trm1.ort_id
# Filter:

AND        (trm1.gesperrt_bis IS NULL OR trm1.gesperrt_bis <= NOW())
AND         trm1.intern_kz = 0
AND         (trm1.tag >= '2019-07-16' OR  trm1.tag_bis >= '2019-07-16' )
AND         (trm1.tag <= '2020-07-15' OR  trm1.tag_bis <= '2020-07-15' )
AND          trm1.ort_id IN (12694,12694,11887,12522,12548,11900,12520,12695,11908,11871,10134,12693,11888,11905,12510,12529,12547,11898,12531,11901,11916,10133,11891,12696,11857,12523,12528,11899)
ORDER BY  distanz_km, trm1.tag, festival_id, trm1.uhr 
LIMIT 0,25