我有以下MySQL表,我想做到RVR11(500)与php var $ RVR11相等
我有此代码,但是它不起作用。
$servername = "localhost";
$username = "root";
$password = "";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$price = mysql_query("SELECT RVR11 FROM tablename");
$result = mysql_fetch_array($RVR11);
echo $result['RVR11'];
很抱歉这个初学者的问题。
答案 0 :(得分:0)
您应该在进行任何查询之前选择一个数据库,您可以将第四个参数传递给# since first letter is not a number you can use substring
MyModel.objects.all().extra({
'unsigned_desc': "CAST(substring(desc, 2) AS UNSIGNED)"
}).order_by('unsigned_desc')
构造函数。