The above MySQL statement decodes the encoded string 'mytext' as specified in the argument and returns the original string.
Sample Output:
mysql> SELECT DECODE(ENCODE('mytext','mykeystring'),'mykeystring'); +------------------------------------------------------+ | DECODE(ENCODE('mytext','mykeystring'),'mykeystring') | +------------------------------------------------------+ | mytext | +------------------------------------------------------+ 1 row in set (0.00 sec)PHP script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="//www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>example-decode - php mysql examples | w3resource</title> </head> <body> <?php echo "<h2>Retrieving the decrypted data from encrypted 'description' column from 'testtable' : </h2>"; echo "<table border='1' style='border-collapse: collapse; border-color: silver;'>"; echo "<tr style='font-weight: bold;'>"; echo "<td width='100' align='center'>Description</td><td width='100' align='center'>DECODE(description,'mypassw')</td>"; echo "</tr>"; include("../dbopen.php"); $result = mysql_query("SELECT description,DECODE(description,'mypassw') FROM testtable"); while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td align='center' width='200'>" . $row[" description"] . "</td>"; echo "<td align='center' width='200'>" . $row[" DECODE(description,'mypassw')"] . "</td>"; echo "</tr>"; } echo "</table>"; ?> </body> </html>View the example in browser>>
Example : MySQL decode() function using table
Sample table: testtable
Code:
SELECT description, DECODE(description,'mypassw') FROM testtable;Explanation:
The above MySQL statement retrieves the decoded data from encoded 'description' column from 'testtable'.
Begitu suatu kondisi ditemukan benar, fungsi MySQL CASE akan mengembalikan hasilnya dan tidak mengevaluasi kondisinya lebih jauh.result_1, result_2, … result_nNilai yang dihasilkan ketika hasil dari suatu kondisi itu ditentukan benar.Catatan- Jika tidak ada kondisi yang benar, maka fungsi KASUS akan mengembalikan nilai pada klausa ELSE.
- Jika klausa ELSE dihilangkan dan kondisi tidak ditemukan benar, maka pernyataan KASUS akan mengembalikan NULL.
Berlaku pada versi MySQL
Fungsi MySQL CASE akan berfungsi berdasarkan versi MySQL:
- MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23.3
Mari kita lihat beberapa contoh fungsi MySQL CASE dan jelajahi bagaimana cara menggunakan fungsi CASE di MySQL.
Contoh – Termasuk ekspresi (includes expression)Anda bisa menggunakan fungsi MySQL CASE dalam pernyataan SQL di mana ungkapan disertakan.
1
2
3
4
5
6
7
SELECT supplier_id,
CASE quantity
WHEN > 10 THEN 'The quantity is greater than 10'
WHEN = 10 THEN 'The quantity is 10'
ELSE 'The quantity is something else'
END
FROM suppliers;
Dalam contoh fungsi MySQL CASE ini, sebuah ungkapan belum disertakan sehingga setiap kondisi dievaluasi secara individual dan dapat benar-benar berbeda dan unik. Tutorial Encode Dan Decode JSON Dengan PHP MySQL 0 ratings0% found this document useful (0 votes)Uploaded by
Ian Ardiansyah
Document Information
click to expand document informationDescription:
ok deh
Copyright
© © All Rights Reserved
Available Formats
PDF, TXT or read online from Scribd
Share this document
Share or Embed Document
Sharing Options
- Share with Email, opens mail client
Email
Did you find this document useful?
0%0% found this document useful, Mark this document as useful
0%0% found this document not useful, Mark this document as not useful
Is this content inappropriate?
Download now
SaveSave Tutorial Encode Dan Decode JSON Dengan PHP MySQL For Later
0 ratings0% found this document useful (0 votes)
Tutorial Encode Dan Decode JSON Dengan PHP MySQL
Uploaded by
Ian ArdiansyahDescription:
ok deh
SaveSave Tutorial Encode Dan Decode JSON Dengan PHP MySQL For Later
0%0% found this document useful, Mark this document as useful
0%0% found this document not useful, Mark this document as not useful
EmbedShare
PrintDownload now
Jump to Page
You are on page 1of 6Search inside document
You're Reading a Free Preview
Pages 4 to 5 are not shown in this preview.
Reward Your Curiosity
Everything you want to read.
Anytime. Anywhere. Any device.
No Commitment. Cancel anytime.
Share this document
Share or Embed Document
Sharing Options
- Share with Email, opens mail client