Kako ne pisati SQL upite!

Započeo holodoc, 01.09.2009, 13:03

prethodna tema - sledeća tema

holodoc

Preuzeto sa http://www.devprotalk.com/showthread.php?t=4920

CitatSELECT DISTINCT users.id, users.membership, (((acos(sin((35.7589*pi()/180)) * sin((users.latitude*pi()/180))+cos((35.7589*pi()/180)) * cos((users.latitude*pi()/180)) * cos(((-78.7798- users.longitude)*pi()/180))))*180/pi())*60*1.1515) as distance
FROM users
INNER JOIN laston ON users.id = laston.user_id INNER JOIN z_9 AS s9 ON users.id = s9.user_id INNER JOIN z_12 AS s12 ON users.id = s12.user_id INNER JOIN z_13 AS s13 ON users.id = s13.user_id INNER JOIN z_14 AS s14 ON users.id = s14.user_id INNER JOIN z_15 AS s15 ON users.id = s15.user_id INNER JOIN z_16 AS s16 ON users.id = s16.user_id INNER JOIN z_17 AS s17 ON users.id = s17.user_id INNER JOIN z_18 AS s18 ON users.id = s18.user_id INNER JOIN z_19 AS s19 ON users.id = s19.user_id INNER JOIN z_21 AS s21 ON users.id = s21.user_id INNER JOIN z_22 AS s22 ON users.id = s22.user_id INNER JOIN z_23 AS s23 ON users.id = s23.user_id INNER JOIN z_24 AS s24 ON users.id = s24.user_id INNER JOIN z_25 AS s25 ON users.id = s25.user_id INNER JOIN z_27 AS s27 ON users.id = s27.user_id INNER JOIN z_29 AS s29 ON users.id = s29.user_id INNER JOIN z_31 AS s31 ON users.id = s31.user_id INNER JOIN z_32 AS s32 ON users.id = s32.user_id INNER JOIN z_33 AS s33 ON users.id = s33.user_id INNER JOIN z_35 AS s35 ON users.id = s35.user_id INNER JOIN z_38 AS s38 ON users.id = s38.user_id INNER JOIN z_39 AS s39 ON users.id = s39.user_id INNER JOIN z_40 AS s40 ON users.id = s40.user_id INNER JOIN z_41 AS s41 ON users.id = s41.user_id INNER JOIN z_42 AS s42 ON users.id = s42.user_id INNER JOIN z_50 AS s50 ON users.id = s50.user_id INNER JOIN z_51 AS s51 ON users.id = s51.user_id INNER JOIN z_53 AS s53 ON users.id = s53.user_id INNER JOIN z_55 AS s55 ON users.id = s55.user_id INNER JOIN z_58 AS s58 ON users.id = s58.user_id INNER JOIN z_60 AS s60 ON users.id = s60.user_id
WHERE 1 AND users.gender = '4112' AND users.seeking = '4092' AND (s9.option_id = '137' OR s9.option_id = '138' OR s9.option_id = '139' OR s9.option_id = '140' OR s9.option_id = '141' OR s9.option_id = '142' OR s9.option_id = '433' OR s9.option_id = '434' OR s9.option_id = '481' OR s9.option_id = '482') AND (s12.option_id = '214' OR s12.option_id = '215' OR s12.option_id = '216' OR s12.option_id = '217' OR s12.option_id = '218' OR s12.option_id = '220') AND (s13.option_id = '221' OR s13.option_id = '222' OR s13.option_id = '223' OR s13.option_id = '224' OR s13.option_id = '225' OR s13.option_id = '226' OR s13.option_id = '227' OR s13.option_id = '429' OR s13.option_id = '435' OR s13.option_id = '495') AND (s14.option_id = '228' OR s14.option_id = '229' OR s14.option_id = '230' OR s14.option_id = '231' OR s14.option_id = '488' OR s14.option_id = '489' OR s14.option_id = '646') AND (s15.option_id = '232' OR s15.option_id = '233' OR s15.option_id = '234' OR s15.option_id = '645') AND (s16.option_id = '238' OR s16.option_id = '239' OR s16.option_id = '240') AND (s17.option_id = '242' OR s17.option_id = '243' OR s17.option_id = '244' OR s17.option_id = '245' OR s17.option_id = '246' OR s17.option_id = '436') AND (s18.option_id = '248' OR s18.option_id = '249' OR s18.option_id = '250' OR s18.option_id = '251' OR s18.option_id = '252' OR s18.option_id = '253' OR s18.option_id = '254' OR s18.option_id = '437') AND (s19.option_id = '256' OR s19.option_id = '257' OR s19.option_id = '258' OR s19.option_id = '259' OR s19.option_id = '260' OR s19.option_id = '261' OR s19.option_id = '262' OR s19.option_id = '263' OR s19.option_id = '264' OR s19.option_id = '265') AND (s21.option_id = '276' OR s21.option_id = '277' OR s21.option_id = '278' OR s21.option_id = '279' OR s21.option_id = '280' OR s21.option_id = '281' OR s21.option_id = '282' OR s21.option_id = '283') AND (s22.option_id = '285' OR s22.option_id = '286' OR s22.option_id = '287' OR s22.option_id = '288' OR s22.option_id = '492' OR s22.option_id = '493' OR s22.option_id = '494') AND (s23.option_id = '290' OR s23.option_id = '291' OR s23.option_id = '292' OR s23.option_id = '491' OR s23.option_id = '663') AND (s24.option_id = '294' OR s24.option_id = '295' OR s24.option_id = '296' OR s24.option_id = '297' OR s24.option_id = '298') AND (s25.option_id = '299' OR s25.option_id = '300' OR s25.option_id = '301' OR s25.option_id = '302' OR s25.option_id = '454' OR s25.option_id = '455') AND (s27.option_id = '312' OR s27.option_id = '313' OR s27.option_id = '314' OR s27.option_id = '315' OR s27.option_id = '316' OR s27.option_id = '317' OR s27.option_id = '318' OR s27.option_id = '319' OR s27.option_id = '320' OR s27.option_id = '344') AND (s29.option_id = '321' OR s29.option_id = '322' OR s29.option_id = '323' OR s29.option_id = '324' OR s29.option_id = '325' OR s29.option_id = '326' OR s29.option_id = '327' OR s29.option_id = '328' OR s29.option_id = '329' OR s29.option_id = '330') AND (s31.option_id = '333' OR s31.option_id = '334' OR s31.option_id = '335' OR s31.option_id = '336' OR s31.option_id = '337' OR s31.option_id = '338' OR s31.option_id = '339' OR s31.option_id = '341' OR s31.option_id = '342') AND (s32.option_id = '348' OR s32.option_id = '350' OR s32.option_id = '351' OR s32.option_id = '352' OR s32.option_id = '353' OR s32.option_id = '354' OR s32.option_id = '355' OR s32.option_id = '356' OR s32.option_id = '357' OR s32.option_id = '358') AND (s33.option_id = '362' OR s33.option_id = '363' OR s33.option_id = '364' OR s33.option_id = '365' OR s33.option_id = '366' OR s33.option_id = '367' OR s33.option_id = '368' OR s33.option_id = '369' OR s33.option_id = '370' OR s33.option_id = '371') AND (s35.option_id = '372' OR s35.option_id = '373' OR s35.option_id = '374' OR s35.option_id = '375' OR s35.option_id = '449' OR s35.option_id = '450' OR s35.option_id = '567' OR s35.option_id = '568' OR s35.option_id = '569' OR s35.option_id = '571') AND (s38.option_id = '376' OR s38.option_id = '377' OR s38.option_id = '378' OR s38.option_id = '379' OR s38.option_id = '380' OR s38.option_id = '381' OR s38.option_id = '382' OR s38.option_id = '383' OR s38.option_id = '384' OR s38.option_id = '385') AND (s39.option_id = '386' OR s39.option_id = '387' OR s39.option_id = '388' OR s39.option_id = '389' OR s39.option_id = '390' OR s39.option_id = '391' OR s39.option_id = '392' OR s39.option_id = '393' OR s39.option_id = '394' OR s39.option_id = '395') AND (s40.option_id = '402' OR s40.option_id = '403' OR s40.option_id = '404' OR s40.option_id = '405' OR s40.option_id = '406' OR s40.option_id = '407' OR s40.option_id = '408' OR s40.option_id = '409' OR s40.option_id = '410' OR s40.option_id = '411') AND (s41.option_id = '413' OR s41.option_id = '414' OR s41.option_id = '415' OR s41.option_id = '416' OR s41.option_id = '417' OR s41.option_id = '418' OR s41.option_id = '419') AND (s42.option_id = '421' OR s42.option_id = '422' OR s42.option_id = '423' OR s42.option_id = '424' OR s42.option_id = '425' OR s42.option_id = '426' OR s42.option_id = '427' OR s42.option_id = '453' OR s42.option_id = '641' OR s42.option_id = '643') AND (s50.option_id = '496' OR s50.option_id = '497' OR s50.option_id = '498' OR s50.option_id = '499' OR s50.option_id = '500' OR s50.option_id = '501' OR s50.option_id = '502' OR s50.option_id = '503' OR s50.option_id = '504' OR s50.option_id = '505') AND (s51.option_id = '509' OR s51.option_id = '510' OR s51.option_id = '511' OR s51.option_id = '512' OR s51.option_id = '513' OR s51.option_id = '514' OR s51.option_id = '515' OR s51.option_id = '516' OR s51.option_id = '517' OR s51.option_id = '518') AND (s53.option_id = '538' OR s53.option_id = '539' OR s53.option_id = '540' OR s53.option_id = '541' OR s53.option_id = '542' OR s53.option_id = '543' OR s53.option_id = '544' OR s53.option_id = '545' OR s53.option_id = '546' OR s53.option_id = '547') AND (s55.option_id = '4152' OR s55.option_id = '4162' OR s55.option_id = '4172' OR s55.option_id = '4182' OR s55.option_id = '4192' OR s55.option_id = '4202' OR s55.option_id = '4212' OR s55.option_id = '4222' OR s55.option_id = '4232' OR s55.option_id = '4242') AND (s58.option_id = '605' OR s58.option_id = '606' OR s58.option_id = '607' OR s58.option_id = '608' OR s58.option_id = '609' OR s58.option_id = '610' OR s58.option_id = '611' OR s58.option_id = '612' OR s58.option_id = '613' OR s58.option_id = '614') AND (s60.option_id = '682' OR s60.option_id = '683') AND users.approved = '1' AND users.deleted = '0' and users.main_photo_id !=0 AND (users.latitude > 35.3239421622 AND users.latitude < 36.1938578378) AND (users.longitude > -79.3142578966 AND users.longitude < -78.2453421034) AND users.dob > '1957-03-19' AND users.dob < '1988-03-19' AND users.id != '1' AND users.id NOT IN (SELECT blocked_user_id FROM blocked WHERE user_id = '1') AND users.id NOT IN (SELECT user_id FROM personal_definitions_attention) ORDER BY distance ASC LIMIT 500
<?php
abstract class Ignorance extends Stupidity implements Unavoidable 
    private function 
__construct(){
        
parent::__destruct();
    }; 

// EOF -> life.php

Marko Аcović

Covece, koji JOIN :P. Interesuje me samo da li je ovim upitom uspeo da srusi server B-)