Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HELP] SQL
15-08-2011, 10:55 AM,
Post: #1
[HELP] SQL
Database: kolej
Table: student

mysql> select * from student;
Code:
+------+----------------+--------------+--------------+------------+-----------+
| ID   | nama_pelajar   | no_kp        | tarikh_lahir | asal       | no_matrik |
+------+----------------+--------------+--------------+------------+-----------+
|  101 | Mohd Azmi      | 910725016255 | 1991-07-25   | Johor      | 24678     |
|  102 | Mohd Khairudin | 891231018827 | 1989-12-31   | Johor      | 13674     |
|  103 | Ahmad Idham    | 901112128989 | 1990-11-12   | Sabah      | 42184     |
|  104 | Mohamad Zabur  | 910831126855 | 1990-08-31   | Sabah      | 42374     |
|  105 | Mohamad Takwim | 801002146839 | 1980-10-21   | Selangor   | 14882     |
|  106 | Nur Amira      | 880923011468 | 1988-09-23   | Johor      | 11238     |
|  107 | Siti Aminah    | 850222109982 | 1985-02-22   | Selangor   | 10483     |
|  108 | Nur Adila      | 870623116244 | 1987-06-23   | Terengganu | 11262     |
|  109 | Nur Rafidah    | 890909112228 | 1989-09-09   | Terengganu | 11537     |
|  110 | Nur Sakinah    | 910101118288 | 1991-01-01   | Terengganu | 11987     |
+------+----------------+--------------+--------------+------------+-----------+
10 rows in set (0.00 sec)

Soalan:
Paparkan nama pelajar perempuan.

Gender tiada, jadi aku tak boleh guna WHERE. TBDians, harap beri tunjuk ajar. Terima kasih GayFace
Reply
15-08-2011, 10:59 AM,
Post: #2
RE: [HELP] SQL
xde genre ke ?
kalau ikut full name leh tarik gune binti
Saya Kene Hack Oleh Budak MMU (Hebat abang mmu ni..Ajar boleh x ) GayFace
Reply
15-08-2011, 11:01 AM,
Post: #3
RE: [HELP] SQL
(15-08-2011, 10:59 AM)noob_crownclown Wrote: xde genre ke ?
kalau ikut full name leh tarik gune binti

Berdasarkan apa yang tertera sahaja GayFace
Macam mana nak jawab soalan ni? kalau guna BETWEEN, LIKE, IS atau EXIST?
Reply
15-08-2011, 11:03 AM,
Post: #4
RE: [HELP] SQL
check kad pengenalan genap ke ganjil ;d wajib guna sql query je ke? ;d

  ▲
▲ ▲
Spoiler:

surah Ali Imran Ayat 31

Reply
15-08-2011, 11:04 AM,
Post: #5
RE: [HELP] SQL
owh3..aku lupe plak beza dari ic genap n ganjil
selalnyer orang gune like ..kalo tak silap
Saya Kene Hack Oleh Budak MMU (Hebat abang mmu ni..Ajar boleh x ) GayFace
Reply
15-08-2011, 11:05 AM,
Post: #6
RE: [HELP] SQL
(15-08-2011, 11:03 AM)ak47suk1 Wrote: check kad pengenalan genap ke ganjil ;d wajib guna sql query je ke? ;d

Tahu dah tentang IC tu, cuma kurang ilmu tentang SQL ni. Nak search kat google pun tak tahu apa keyword perlu search. *WILDCARD* <~ r3v3r bagitahu GayFace
Reply
15-08-2011, 11:07 AM,
Post: #7
RE: [HELP] SQL
SELECT no_kp FROM student WHERE no_kp % 2 = 1
Reply
15-08-2011, 11:08 AM, (This post was last modified: 15-08-2011, 11:09 AM by JejakaPemalu.)
Post: #8
RE: [HELP] SQL
Spoiler:

(15-08-2011, 10:55 AM)amsama Wrote: Database: kolej
Table: student

mysql> select * from student;
Code:
+------+----------------+--------------+--------------+------------+-----------+
| ID   | nama_pelajar   | no_kp        | tarikh_lahir | asal       | no_matrik |
+------+----------------+--------------+--------------+------------+-----------+
|  101 | Mohd Azmi      | 910725016255 | 1991-07-25   | Johor      | 24678     |
|  102 | Mohd Khairudin | 891231018827 | 1989-12-31   | Johor      | 13674     |
|  103 | Ahmad Idham    | 901112128989 | 1990-11-12   | Sabah      | 42184     |
|  104 | Mohamad Zabur  | 910831126855 | 1990-08-31   | Sabah      | 42374     |
|  105 | Mohamad Takwim | 801002146839 | 1980-10-21   | Selangor   | 14882     |
|  106 | Nur Amira      | 880923011468 | 1988-09-23   | Johor      | 11238     |
|  107 | Siti Aminah    | 850222109982 | 1985-02-22   | Selangor   | 10483     |
|  108 | Nur Adila      | 870623116244 | 1987-06-23   | Terengganu | 11262     |
|  109 | Nur Rafidah    | 890909112228 | 1989-09-09   | Terengganu | 11537     |
|  110 | Nur Sakinah    | 910101118288 | 1991-01-01   | Terengganu | 11987     |
+------+----------------+--------------+--------------+------------+-----------+
10 rows in set (0.00 sec)

Soalan:
Paparkan nama pelajar perempuan.

Gender tiada, jadi aku tak boleh guna WHERE. TBDians, harap beri tunjuk ajar. Terima kasih GayFace


Code:
SELECT  no_kp , CASE WHEN ABS( no_kp ) % 2 = 1 THEN 'LELAKI' ELSE 'PEREMPUAN' END FROM student;
However near and dear you are with wife, children, friends, families they are not you; they are outside of you. The inside of you says who is near. If nothing is said than you are foreveralone. Raise your iman and you shall not be foreveralone.
Reply
15-08-2011, 11:10 AM,
Post: #9
RE: [HELP] SQL
guna number ic je la kot.genap = female,ganjil = male,genjil=shemale
[Image: 3EsGZgg.png]
uno akhirnya kau ngaku gak ye
Reply
15-08-2011, 11:13 AM,
Post: #10
RE: [HELP] SQL
(15-08-2011, 11:07 AM)r3v3r7 Wrote: SELECT nama_pelajar FROM student WHERE no_kp % 2 = 1

mysql> select nama_pelajar from student where no_kp % 2=1;
Code:
+----------------+
| nama_pelajar   |
+----------------+
| Mohd Azmi      |
| Mohd Khairudin |
| Ahmad Idham    |
| Mohamad Zabur  |
| Mohamad Takwim |
+----------------+
5 rows in set (0.00 sec)

Keluar nama lelaki Sad betul2 ;d nih... ;d
Boleh bagi pencerahan terhadap syntax "2=1"?
Reply
15-08-2011, 11:17 AM,
Post: #11
RE: [HELP] SQL
ayyak.. mmg kne step by step la ko nih..adess..think br0 GayFace

2=1 tukar la 2=0

yg tu modulo operation je.. what is modulo? dalam bahasa, baki bila ko dah bahagi..baki tu la yg menentukan genap ganjil.. klo xde baki, so genap la no tu.. klo ade baki ganjil lah ia..

//aku edit yg atas2 sbb typo.. patut no_kp tp aku tertulis nama_pelajar..sorry..
Reply
15-08-2011, 11:27 AM,
Post: #12
RE: [HELP] SQL
(15-08-2011, 11:08 AM)Jejaka Pemalu Wrote:
Code:
SELECT  no_kp , CASE WHEN ABS( no_kp ) % 2 = 1 THEN 'LELAKI' ELSE 'PEREMPUAN' END FROM student;

Rasa macam advanced je syntax ni. Saya baru belajar Sad Ia memisahkan gender lelaki dan perempuan mengikut IC. TQ shyguy +rape i learnt someting new today.

(15-08-2011, 11:17 AM)r3v3r7 Wrote: ayyak.. mmg kne step by step la ko nih..adess..think br0 GayFace

2=1 tukar la 2=0

yg tu modulo operation je.. what is modulo? dalam bahasa, baki bila ko dah bahagi..baki tu la yg menentukan genap ganjil.. klo xde baki, so genap la no tu.. klo ade baki ganjil lah ia..

//aku edit yg atas2 sbb typo.. patut no_kp tp aku tertulis nama_pelajar..sorry..

Ahaha aku dah think perabis sampai kering otak. Baru2 belajar je sql ni. Dia punya exercise punyalah perah otak @@ TQ ia berjaya keluarkan nama perempuan sahaja +rape
Reply
15-08-2011, 12:11 PM, (This post was last modified: 15-08-2011, 12:12 PM by JejakaPemalu.)
Post: #13
RE: [HELP] SQL
Spoiler:
(15-08-2011, 11:27 AM)amsama Wrote:
(15-08-2011, 11:08 AM)Jejaka Pemalu Wrote:
Code:
SELECT  no_kp , CASE WHEN ABS( no_kp ) % 2 = 1 THEN 'LELAKI' ELSE 'PEREMPUAN' END FROM student;

Rasa macam advanced je syntax ni. Saya baru belajar Sad Ia memisahkan gender lelaki dan perempuan mengikut IC. TQ shyguy +rape i learnt someting new today.

(15-08-2011, 11:17 AM)r3v3r7 Wrote: ayyak.. mmg kne step by step la ko nih..adess..think br0 GayFace

2=1 tukar la 2=0

yg tu modulo operation je.. what is modulo? dalam bahasa, baki bila ko dah bahagi..baki tu la yg menentukan genap ganjil.. klo xde baki, so genap la no tu.. klo ade baki ganjil lah ia..

//aku edit yg atas2 sbb typo.. patut no_kp tp aku tertulis nama_pelajar..sorry..

Ahaha aku dah think perabis sampai kering otak. Baru2 belajar je sql ni. Dia punya exercise punyalah perah otak @@ TQ ia berjaya keluarkan nama perempuan sahaja +rape



Aku wat kalau lelaki dia keluar lelaki method dia sama aje ngan r3v3r7..cuma ada case aje dalam tuh..sama ada lelaki buat apa perempuan buat apa..pastu aku bubuh absolute value. manalah tau ada org gi bubuh negative value dalam ic dia..Big Grin
However near and dear you are with wife, children, friends, families they are not you; they are outside of you. The inside of you says who is near. If nothing is said than you are foreveralone. Raise your iman and you shall not be foreveralone.
Reply


Forum Jump: