Stránka: 1 z 1
| [ Príspevkov: 9 ] | |
Autor | Správa |
---|
Registrovaný: 01.05.05 Príspevky: 13415 Témy: 1496 | 1496 Bydlisko: Bratislava |
Viem nejak zoradit vysledok SELECTU pod
[c]SELECT * FROM tabulke WHERE id IN (3, 5, 1, 10, 9) ORDER BY ....[/c]
chcem aby dany vysledok bol zoradeny tak ako ide v IN()
skusal som
[c]SELECT * FROM tabulke WHERE id IN (3, 5, 1, 10, 9) ORDER BY id FIELD(3, 5, 1, 10, 9) SELECT * FROM tabulke WHERE id IN (3, 5, 1, 10, 9) ORDER BY id instr(3, 5, 1, 10, 9, id)[/c]
ale myslim ze to nefunguje spravne, viete niekto helfnut?
_________________ Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 11 Enterprise | APC Back-UPS BE-850 VA | Lenovo ThinkPad X250 & Microsoft Windows 11 Professional | iPhone 15 Pro 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu 24.04.1 LTS |
|
Registrovaný: 27.07.07 Príspevky: 3948 Témy: 51 | 51 Bydlisko: Bratislava |
ORDER BY FIELD(id, 3, 5, 1, 10, 9)
_________________ NTB: Acer Aspire 4820TG 14" | CPU: Intel Core i5 2,53 GHz | VGA: ATI Mobility Radeon HD5650 1GB | RAM: 8GB DDR3 1066 MHz | HDD: 1TB SSD WD BLUE |
|
Registrovaný: 01.05.05 Príspevky: 13415 Témy: 1496 | 1496 Bydlisko: Bratislava |
Skusal som a vrati mi to iny vysledok ako ked spravim
[c]SELECT * FROM tabulke WHERE id IN (3, 5, 1, 10, 9) ORDER BY id = 3 DESC, id = 5 DESC, id = 1 DESC, id = 10 DESC, id = 9 DESC[/c]
a uz netusim vobec preco, takyto select mi zobrazi spravne, ten FIELD() by mal robit to iste ze?
_________________ Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 11 Enterprise | APC Back-UPS BE-850 VA | Lenovo ThinkPad X250 & Microsoft Windows 11 Professional | iPhone 15 Pro 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu 24.04.1 LTS |
|
Registrovaný: 27.07.07 Príspevky: 3948 Témy: 51 | 51 Bydlisko: Bratislava |
Aky vysledok ti to vracia? Mozes este vyskusat ORDER BY FIND_IN_SET(id, '3,5,1,10,9')
_________________ NTB: Acer Aspire 4820TG 14" | CPU: Intel Core i5 2,53 GHz | VGA: ATI Mobility Radeon HD5650 1GB | RAM: 8GB DDR3 1066 MHz | HDD: 1TB SSD WD BLUE |
|
Registrovaný: 01.05.05 Príspevky: 13415 Témy: 1496 | 1496 Bydlisko: Bratislava |
Vracia mi to uplne inac zoradeny vysledok, tento druhy FIND_IN_SET som uz tiez skusal a to mi zas zoradi podla id, takze som nasiel dobre funkcie na to, len mi to akosi nefunguje :/
// Spojený príspevok Str 31.12.14 13:18
a pride mi blbe mat za order by 30 id ako som uviedol co mi funguje, isto to ma nejaky vplyv na vykon, ci?
_________________ Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 11 Enterprise | APC Back-UPS BE-850 VA | Lenovo ThinkPad X250 & Microsoft Windows 11 Professional | iPhone 15 Pro 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu 24.04.1 LTS |
|
Registrovaný: 27.07.07 Príspevky: 3948 Témy: 51 | 51 Bydlisko: Bratislava |
Zaujimave, mne davaju vsetky varianty rovnaky vysledok. Nieco mas pokazene
_________________ NTB: Acer Aspire 4820TG 14" | CPU: Intel Core i5 2,53 GHz | VGA: ATI Mobility Radeon HD5650 1GB | RAM: 8GB DDR3 1066 MHz | HDD: 1TB SSD WD BLUE |
|
Registrovaný: 01.05.05 Príspevky: 13415 Témy: 1496 | 1496 Bydlisko: Bratislava |
Mam na tomto selecte nieco zle? skusam konkretne toto a zobrazi ine zoradenie ako je v ()
[c]SELECT * FROM `city` WHERE id IN (3, 722, 1807, 1423, 1985) ORDER BY FIND_IN_SET(id, '3, 722, 1807, 1423, 1985')[/c]
zoradi mi to: 722 1423 1807 1985 3
// Spojený príspevok Str 31.12.14 13:43
ahaaa to skrz toho ze mam medzery za ciarkou zjavne...
// Spojený príspevok Str 31.12.14 13:44
presne to bol problem, tam kde skladam ten sql dotaz, tak som generoval medzeru za ciarkou, necakal som ze by s tym nevedel mysql server poradit, to je taky problem v medzerach?
_________________ Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 11 Enterprise | APC Back-UPS BE-850 VA | Lenovo ThinkPad X250 & Microsoft Windows 11 Professional | iPhone 15 Pro 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu 24.04.1 LTS |
|
Registrovaný: 27.07.07 Príspevky: 3948 Témy: 51 | 51 Bydlisko: Bratislava |
Je tam vyzadovana ciarka ako oddelovac hodnot, preto som ti ten priklad pisal bez medzier
_________________ NTB: Acer Aspire 4820TG 14" | CPU: Intel Core i5 2,53 GHz | VGA: ATI Mobility Radeon HD5650 1GB | RAM: 8GB DDR3 1066 MHz | HDD: 1TB SSD WD BLUE |
|
Registrovaný: 01.05.05 Príspevky: 13415 Témy: 1496 | 1496 Bydlisko: Bratislava |
ano to viem, ja som hned pouzival , ako oddelovac, ale neuvedomil som si ze som tam za ciarku daval aj medzeru a preto mi to zobrazovalo v php ine vysledky ako v phpmyadmine, necakal by som ze mysql server to nespracuje ak tam je medzera a taku chybu som robil na viac miestach ale tam nepouzivam radenie podla toho ako to je v IN, tak ale aj tak som vsade medzeru zmazal pre istotu ale diky za pomoc, ze som si vsimol svoju chybu
_________________ Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 11 Enterprise | APC Back-UPS BE-850 VA | Lenovo ThinkPad X250 & Microsoft Windows 11 Professional | iPhone 15 Pro 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu 24.04.1 LTS |
|
Stránka: 1 z 1
| [ Príspevkov: 9 ] | |
|