dear, everyone...
i need solutions.
i have several tables in a database.
this is tabel_jawab

kd_jwb 	nis 	kd_mk 	jwb1 	jwb2 	jwb3 	jwb4 	jwb5
  321 	654 	 2 	 A 	 B 	 A 	 C 	  B

i input them via jsp to mysql table.
i have these table too named tabel_kunci

kd_jwb 	kd_mk 	Kjwb1 	Kjwb2 	Kjwb3 	Kjwb4 	Kjwb5
321 	2 	A 	C 	C 	A 	B

i put them into mysql table via jsp too.(it works well)

i want to compare the with a condition that if the value of "jwb1" in tabel_jwb exactly equals with "Kjwb1" in tabel_kunci then i can give value = 2,5 else value= 0.

do i need another column named "value" to keep 2,5 or 0 ?
will you tell me the query ?

i use

SELECT tabel_siswa.nis,tabel_siswa.nama,tabel_siswa.kelas,tabel_jawab.jwb1,tabel_jawab.jwb2,tabel_jawab.jwb3,tabel_jawab.jwb4,tabel_jawab.jwb5  from tabel_siswa,tabel_jawab where tabel_siswa.nis=tabel_jawab.nis AND tabel_mk.kd_mk=tabel_jawab.kd_mk

but it doesn't work.

please help....
regards


mutawari

Selamat siang,

You are showing two tables jawab and kunci. Your select contains further tables: siswa in from clause and tabel_mk in where clause where the latter is missing in from clause.

There is a further table tabel_jwb mentioned in your last question but one. So which tables are correct? You also need to know all primary and foreign key of your tables in detail. As for example, I myself would say that column kd_jwb, value 321, seems to be kind of primary/foreign key on where joins might function. However, you are using column "nis" in query.

Well, not knowing your tables and keys exactly nobody can help you. Although your select statement is wrong in principle, for that immense lack of information it is impossible to advice you a better one.

Ok, replacing a columns value by another one, e.g. value of Kjwb1 by 2.5 or 0 is usually done by sql CASE function.

-- tesu

dear tesu,
yes that's the problem...what should i use to make it hapen...(i could put value using it)
regards,

andrianto

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.