我有一张像
这样的表格ID | Name | ProdID | Model | StudID
-----------------------------------
1 | A | 3 | hey | 6
2 | B | 4 | he | 7
2 | C | 5 | hi | 8
当Model
为4和5时,我需要将StudID
和N/A
值设为ProdID
ID | Name | ProdID | Model | StudID
-----------------------------------
1 | A | 3 | hey | 6
2 | B | 4 | N/A | N/A
2 | C | 5 | N/A | N/A
这是我迄今为止所做的一小部分
SELECT
ID,
Name,
CASE
WHEN CONVERT(VARCHAR, ProdID) = 4 THEN CONVERT(VARCHAR, Model) = 'N/A'
..
答案 0 :(得分:2)
首先,您需要非常小心类型。
convert()
或cast()
时,包含varchar()
的长度。所以:
SELECT ID, Name, ProdId,
(CASE WHEN ProdId IN (4, 5) THEN Model ELSE 'N/A' END) as Model,
(CASE WHEN ProdId IN (4, 5) THEN CONVERT(VARCHAR(255), StudId) ELSE 'N/A' END) as StudId
...
请注意,您需要转换StudId
,假设该值为整数。
答案 1 :(得分:1)
plotWidth
答案 2 :(得分:1)
试试这个
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
//do whatever want do by these value
print_r($_POST);
//here you have to echo or print the any message for ajax return otherwise ajax not return anything
?>