mysql查出价格最低的那条数据的所有信息的解决方法

2023年7月11日 07:45 by wst

database

在实际业务中经常碰到,请找出价格最低的那条数据的所有信息。

常规方法

筛选最低的价格,然后再根据价格和表本身做表连接。如下:

select s1.*
from specification s1
    inner join (
        select cid, min(price) as price
        from specification
        group by
            cid
    ) s2 on (
        s1.cid = s2.cid
        and s1.price = s2.price
    )

这个代码运行了好长时间,直到有个用户创建了价格相同的两条数据,于是出现了bug。怎么解决接往下看:

解决方法

因为在创建数据的时候,每条记录都有唯一ID,那么我可以根据这个筛选。

select s1.*
from specification s1
    inner join (
        select cid, min(price) as price, min(id) as sid
        from specification
        group by
            cid,price
    ) s2 on (
        s1.cid = s2.cid
        and s1.id = s2.sid
    )

后记:做完后发现不对,于是分组时加上了price字段。

勉励自己,同时给后来人提供帮助!

 


Comments(124) Add Your Comment

Srokzr
buy atorvastatin online <a href="https://lipiws.top/">brand lipitor 10mg</a> atorvastatin 40mg for sale
Jfhpxh
buy baycip for sale - <a href="https://cipropro.top/keflexcapsule/">keflex us</a> augmentin 375mg without prescription
Bykdco
purchase baycip generic - <a href="https://metroagyl.top/cefaclor/">buy cheap keflex</a> buy augmentin 625mg generic
Hisaxt
ciplox without prescription - <a href="https:/septrim.top/">cost ciprofloxacin</a> erythromycin usa
Wpyebl
buy metronidazole generic - <a href="https://metroagyl.top/clindamycin/">cleocin drug</a> zithromax cheap
Emdocc
ivermectin 12mg tablet - <a href="https://keflexin.top/tetracycline/">order sumycin online cheap</a> generic sumycin 250mg
Wtyflz
valacyclovir price - <a href="https://gnantiviralp.com/vermox/">purchase mebendazole online cheap</a> zovirax 400mg over the counter
Ezwmlh
buy generic ampicillin online <a href="https://ampiacil.top/penicillinused/">cheap penicillin</a> buy cheap generic amoxicillin
Ynsyia
flagyl sale - <a href="https://metroagyl.top/clindamycin/">cleocin 300mg over the counter</a> zithromax buy online
Xyxinv
brand lasix - <a href="https://antipathogenc.com/capoten/">buy capoten 25mg sale</a> order capoten 25mg for sale
Ysnjee
glycomet for sale online - <a href="https://gnantiacidity.com/">order metformin 1000mg online</a> lincocin 500mg tablet
Zqyhzt
retrovir 300 mg without prescription - <a href="https://canadiangnp.com/avapro/">avapro uk</a> zyloprim 300mg brand
Tketaz
clozaril buy online - <a href="https://genonlinep.com/coversyl/">order aceon generic</a> brand famotidine
Tdjgxy
buy generic seroquel - <a href="https://gnkantdepres.com/effexor/">order effexor 75mg sale</a> buy eskalith for sale
Ekogsn
order anafranil 25mg - <a href="https://antdeponline.com/tofranil/">imipramine order</a> cheap doxepin
Nbvfxz
order hydroxyzine 10mg generic - <a href="https://antdepls.com/pamelor/">pamelor for sale</a> buy amitriptyline tablets
Xawrgq
order generic augmentin 375mg - <a href="https://atbioinfo.com/septra/">buy septra generic</a> cipro medication
Gtjhso
buy amoxicillin pill - <a href="https://atbioxotc.com/erythromycin/">erythromycin 500mg sale</a> ciprofloxacin uk
Bdcfwm
order zithromax 500mg pills - <a href="https://gncatbp.com/emetronidazole/">purchase flagyl for sale</a> buy generic ciplox
Zfwdkv
purchase cleocin - <a href="https://cadbiot.com/cefixime/">order cefixime 200mg generic</a> chloramphenicol online order
Oxqxlo
stromectol for sale online - <a href="https://antibpl.com/ascefaclor/">order cefaclor</a> order cefaclor 500mg sale
Jmjlnp
cheap albuterol inhalator - <a href="https://antxallergic.com/cvallegra/">allegra for sale online</a> order theo-24 Cr 400mg
Iyfnkg
generic depo-medrol - <a href="https://ntallegpl.com/fluorometholone/">fluorometholone for sale</a> azelastine us
Waglhk
order desloratadine without prescription - <a href="https://rxtallerg.com/getzaditor/">buy zaditor paypal</a> albuterol 4mg ca
Jvjdlm
buy micronase no prescription - <a href="https://prodeprpl.com/pioglitazone30/">pioglitazone 15mg us</a> dapagliflozin 10mg generic
Krggfj
glucophage 1000mg generic - <a href="https://arxdepress.com/sitagliptin50/">cost sitagliptin 100mg</a> precose us
Aahsyo
order prandin 1mg sale - <a href="https://depressinfo.com/jardiance25/">jardiance 10mg uk</a> jardiance 10mg drug
Dmoafe
rybelsus 14 mg cheap - <a href="https://infodeppl.com/ddavpspray/">generic desmopressin</a> buy generic desmopressin online
Ubsvfc
purchase terbinafine online - <a href="https://treatfungusx.com/fulvicin250mg/">order griseofulvin 250mg without prescription</a> griseofulvin medication
Llzdgb
buy ketoconazole generic - <a href="https://antifungusrp.com/itraconazole100/">buy generic sporanox</a> order generic sporanox
Qrtdcz
buy famciclovir no prescription - <a href="https://amvinherpes.com/gnvalaciclovir/">order valaciclovir 500mg</a> valaciclovir 1000mg cost
Eyyhfw
digoxin where to buy - <a href="https://blpressureok.com/furosemidediuret/">lasix 40mg price</a> oral lasix 40mg
Izbpxo
order lopressor 100mg pills - <a href="https://bloodpresspl.com/propranolol/">inderal 10mg brand</a> order adalat 10mg for sale
Pxccdo
buy generic hydrochlorothiazide 25mg - <a href="https://norvapril.com/bisoprolol/">purchase bisoprolol</a> purchase zebeta
Rwyxdd
purchase nitroglycerin generic - <a href="https://nitroproxl.com/valsartan/">diovan 160mg pills</a> order diovan 160mg for sale
Bazrrd
simvastatin sheep - <a href="https://canescholest.com/gemfibrozil/">lopid cupboard</a> atorvastatin polish
Apqfmg
rosuvastatin caution - <a href="https://antcholesterol.com/ezetimibe/">zetia buy stranger</a> caduet online toward
Mjtnui
viagra professional bullet - <a href="https://edsildps.com/viagragold/">viagra gold online fall</a> levitra oral jelly shrug
Rqrgbv
dapoxetine attack - <a href="https://promedprili.com/suhagra/">suhagra awful</a> cialis with dapoxetine pressure
Vozfoe
order cenforce 50mg generic - <a href="https://xcenforcem.com/silagrasildenafil/"></a> brand viagra armor
Tumvjg
brand cialis soar - <a href="https://probrandtad.com/apcalissx/">apcalis elbow</a> penisole ultimate
Dcspgx
brand cialis mental - <a href="https://probrandtad.com/forzestpills/">forzest capital</a> penisole disease
Mqzhyh
cialis soft tabs online brood - <a href="https://supervalip.com/viagrasuperactive/">viagra super active stick</a> viagra oral jelly online slab
Dbjjns
cialis soft tabs online forehead - <a href="https://supervalip.com/levitrasoft/">levitra soft drown</a> viagra oral jelly reader
Skthwt
dapoxetine shower - <a href="https://promedprili.com/viagraplus/">viagra plus steeple</a> cialis with dapoxetine shell
Veeqji
cenforce online excitement - <a href="https://xcenforcem.com/tadaciptadalafil/">tadacip online kneel</a> brand viagra pills straight
Tmkrie
asthma medication drug - <a href="https://bsasthmaps.com/">asthma medication armor</a> inhalers for asthma same
Kbzavm
acne medication express - <a href="https://placnemedx.com/">acne treatment fifty</a> acne treatment activity
Abauvv
pills for treat prostatitis history - <a href="https://xprosttreat.com/">prostatitis pills lower</a> prostatitis pills cheap
Kcwrto
uti medication disappointment - <a href="https://amenahealthp.com/">treatment for uti guess</a> uti treatment mile
Rybptw
claritin pills crime - <a href="https://clatadine.top/">claritin pills amiable</a> claritin pills hat
Cseyuj
valacyclovir pills drift - <a href="https://gnantiviralp.com/">valtrex online sex</a> valtrex pills force
Xvyxbo
priligy pace - <a href="https://prilixgn.top/">priligy thud</a> priligy station
Tixipo
claritin draught - <a href="https://clatadine.top/">claritin shell</a> claritin pills ponder
Wuxvzi
ascorbic acid tone - <a href="https://ascxacid.com/">ascorbic acid couple</a> ascorbic acid per
Bzfvxo
promethazine research - <a href="https://prohnrg.com/">promethazine interval</a> promethazine blank
Zneakq
biaxin clumsy - <a href="https://gastropls.com/mesalaminepl/">mesalamine pills thomas</a> cytotec pills stiff
Efzowp
fludrocortisone toast - <a href="https://gastroplusp.com/">florinef stray</a> lansoprazole immediate
Zjdkjo
order rabeprazole 10mg for sale - <a href="https://gastrointesl.com/metoclopramide/">metoclopramide 10mg without prescription</a> buy domperidone 10mg generic
Crdyto
order bisacodyl 5mg for sale - <a href="https://gastroinfop.com/liv52/">liv52 without prescription</a> buy liv52 10mg generic
Bbimrq
purchase zovirax cream - <a href="https://cerazestrel.com/">oral desogestrel</a> order duphaston sale
Gyyjtd
cheap cotrimoxazole - <a href="https://cotrioxazo.com/">buy bactrim pills</a> tobra 5mg ca
Oduvxo
purchase griseofulvin without prescription - <a href="https://dipyrilx.com/">cost dipyridamole 100mg</a> order gemfibrozil 300 mg for sale
Qpnlmb
order dapagliflozin 10 mg without prescription - <a href="https://sineqpin.com/">sinequan 25mg us</a> buy acarbose 50mg sale
Afydgp
dimenhydrinate tablet - <a href="https://actodronate.com/">pill actonel 35 mg</a> order risedronate 35mg
Uhfpay
order vasotec sale - <a href="https://xalanoprost.com/">brand xalatan</a> xalatan order
Cmrlcn
buy generic etodolac 600 mg - <a href="https://cilosetal.com/">cilostazol 100mg cheap</a> purchase cilostazol generic
Oyndhb
order piroxicam - <a href="https://rivastilons.com/">rivastigmine sale</a> exelon 3mg cheap
Ufckkv
piracetam cost - <a href="https://nootquin.com/sinemet/">sinemet 10mg cost</a> sinemet 20mg generic
Mthmzx
how to get hydrea without a prescription - <a href="https://hydroydrinfo.com/disulfiram/">buy disulfiram 500mg pills</a> methocarbamol price
Vwcsxy
buy generic divalproex for sale - <a href="https://adepamox.com/">order depakote 500mg online</a> order topamax sale
Jngonh
purchase disopyramide phosphate without prescription - <a href="https://anorpica.com/">cheap norpace without prescription</a> thorazine 100mg for sale
Raijdf
how to get aldactone without a prescription - <a href="https://aldantinep.com/dipyridamole/">buy persantine</a> cost revia
Mcjyog
cheap cyclophosphamide tablets - <a href="https://cycloxalp.com/stavudine/">zerit order</a> purchase vastarel
Kmawtc
buy cyclobenzaprine 15mg without prescription - <a href="https://abflequine.com/donepezil/">order generic donepezil</a> vasotec medication
Dglnmn
purchase ondansetron generic - <a href="https://azofarininfo.com/">ondansetron 8mg without prescription</a> order ropinirole 2mg for sale
Ejmsbr
order ascorbic acid 500 mg online cheap - <a href="https://mdacidinfo.com/prochlorperazine/">prochlorperazine drug</a> compro oral
Xutyhj
purchase durex gel sale - <a href="https://xalaplinfo.com/latanoprosteyedrops/">order xalatan without prescription</a> purchase xalatan
Nhhwrq
minoxidil over the counter - <a href="https://hairlossmedinfo.com/finasteridehl/">proscar ca</a> finasteride sale
Fwnqzp
arava 20mg price - <a href="https://infohealthybones.com/cartidin/">cartidin canada</a> purchase cartidin
Zuteow
calan 120mg usa - <a href="https://infoheartdisea.com/atenolol/">tenoretic where to buy</a> cheap tenoretic tablets
Qkgzqz
buy atenolol 100mg generic - <a href="https://heartmedinfox.com/clopidogrel/">order clopidogrel 75mg for sale</a> coreg without prescription
Wudiei
atorlip over the counter - <a href="https://infoxheartmed.com/lisinopril/">lisinopril sale</a> bystolic 5mg ca
Bwruzo
buy generic gasex - <a href="https://herbalinfomez.com/ashwagandha/">order ashwagandha pill</a> cheap diabecon pills
Xwwnxb
norfloxacin where to buy - <a href="https://gmenshth.com/confido/">buy confido pills</a> buy confido no prescription
Sthgwu
speman generic - <a href="https://spmensht.com/finasteride/">order finasteride online</a> order fincar sale
Wfhmjj
purchase finasteride pill - <a href="https://finmenura.com/kamagra/">buy kamagra 200mg sale</a> uroxatral 10mg drug
Kmitcf
terazosin without prescription - <a href="https://hymenmax.com/dutasteride/">avodart tablet</a> order dapoxetine 90mg sale
Mlkdid
order cyclosporine without prescription - <a href="https://asimusxate.com/">imusporin ca</a> gloperba ca
Oqwtsl
buy duphalac bottles - <a href="https://duphalinfo.com/">order duphalac bottless</a> betahistine 16mg ca
Vzzfux
buy calcort pills for sale - <a href="https://lazacort.com/">purchase calcort without prescription</a> order alphagan without prescription
Iqllft
how to buy besivance - <a href="https://besifxcist.com/">where to buy besifloxacin without a prescription</a> order sildamax generic
Ylrtoc
buy generic probenecid online - <a href="https://bendoltol.com/monograph/">monograph over the counter</a> carbamazepine medication
Uwjazc
order neurontin 100mg pills - <a href="https://aneutrin.com/">buy gabapentin for sale</a> purchase azulfidine sale
Nloclg
purchase colospa sale - <a href="https://coloxia.com/pletal/">cilostazol where to buy</a> pletal medication
Mrwmzu
buy celebrex 100mg pills - <a href="https://celespas.com/">celebrex 200mg pill</a> indomethacin over the counter
Kmskkp
buy rumalaya cheap - <a href="https://rumaxtol.com/">rumalaya price</a> elavil 50mg over the counter
Nepdib
buy voltaren 100mg online - <a href="https://dicloltarin.com/">diclofenac online</a> order aspirin 75 mg online
Oelgpl
purchase voveran pills - <a href="https://vovetosa.com/tisosorbide/">buy isosorbide for sale</a> oral nimotop
Vphwwa
buy pyridostigmine 60mg generic - <a href="https://mestonsx.com/">pyridostigmine pills</a> buy azathioprine without a prescription
Lxjeon
buy meloxicam 7.5mg generic - <a href="https://meloxiptan.com/asrizatriptan/">maxalt 10mg uk</a> order toradol 10mg for sale
Qmgvqq
baclofen 10mg pills - <a href="https://baclion.com/">buy baclofen pill</a> order piroxicam 20 mg generic
Wfglhv
cheap artane - <a href="https://voltapll.com/diclofenacgel/">purchase diclofenac gel sale</a> voltaren gel online buy
Etmoff
purchase cyproheptadine online - <a href="https://periheptadn.com/aszanaflex/">tizanidine cost</a> order tizanidine 2mg pills
Wcvpjy
brand accutane - <a href="https://aisotane.com/">buy generic isotretinoin 10mg</a> order deltasone 40mg generic
Irrnef
order cefdinir online - <a href="https://omnixcin.com/aminocycline/"></a> buy generic clindamycin for sale
Oxyobt
buy acticin generic - <a href="https://actizacs.com/asbenzac/">buy benzoyl peroxide cheap</a> order generic tretinoin
Aerims
prednisone 10mg price - <a href="https://apreplson.com/">buy prednisone 5mg</a> elimite tubes
Bpxadd
buy metronidazole generic - <a href="https://ametronles.com/">brand metronidazole 400mg</a> cenforce oral
Ejjxwn
how to buy betnovate - <a href="https://betnoson.com/awdifferin/">brand differin</a> monobenzone price
Cdguvv
buy clindamycin generic - <a href="https://clinycinpl.com/">buy cleocin paypal</a> buy indomethacin generic
Edwzrv
buy augmentin 625mg online cheap - <a href="https://alevonted.com/">levothyroxine sale</a> levoxyl usa
Pzmday
order eurax - <a href="https://aeuracream.com/">buy crotamiton without prescription</a> buy aczone no prescription
Bjnzbq
bupropion 150mg without prescription - <a href="https://bupropsl.com/shuddhaguggulu/">buy shuddha guggulu paypal</a> buy shuddha guggulu tablets
Cioyfh
buy provigil online - <a href="https://sleepagil.com/">buy modafinil 100mg pills</a> purchase melatonin sale
Dxkeug
progesterone 100mg cheap - <a href="https://apromid.com/gynelotrimin/">purchase ponstel generic</a> buy fertomid cheap
Dvaure
capecitabine ca - <a href="https://xelocap.com/">buy xeloda for sale</a> cheap danocrine 100 mg
Akaabg
order norethindrone 5mg pills - <a href="https://norethgep.com/bimatoprost/">where can i buy careprost</a> yasmin for sale online
Mdkjck
purchase alendronate pill - <a href="https://pilaxmax.com/tamoxifen/">nolvadex for sale</a> purchase medroxyprogesterone generic
Pajyic
buy cheap cabergoline - <a href="https://adostilin.com/alesse/">alesse pills</a> cheap alesse for sale
Bzwezf
order yasmin online cheap - <a href="https://festrolp.com/ginette-35/">order ginette 35 without prescription</a> where can i buy arimidex
Ngzker
シルデナフィル どこで買える - <a href="https://jpedpharm.com/">正規品タダラフィル錠の正しい処方</a> シアリス どこで買える
Imghnz
プレドニン通販 安全 - <a href="https://jpaonlinep.com/jazithromycin/">ジスロマック 海外通販</a> ジスロマック 値段
Vohvav
プレドニン通販 - <a href="https://jpanfarap.com/jpaaccutane/">イソトレチノイン どこで買える</a> アキュテイン の購入