Php 如何创建有限制的Mysql Select语句
你好。我需要帮助做一个mysql选择,其中wins中的值高于100?因此,它只选择拥有超过100个win's的用户 然后我需要将每一个插入到一个表中 这是我到目前为止所拥有的Php 如何创建有限制的Mysql Select语句,php,mysql,sql,Php,Mysql,Sql,你好。我需要帮助做一个mysql选择,其中wins中的值高于100?因此,它只选择拥有超过100个win's的用户 然后我需要将每一个插入到一个表中 这是我到目前为止所拥有的 <?php // i have toke my connect out // Get all the data from the "example" table $result = mysql_query("SELECT * FROM users") or die(mysql_error()); echo
<?php
// i have toke my connect out
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM users")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>username</th> <th>wins</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['username'];
echo "</td><td>";
echo $row['wins'];
echo "</td></tr>";
}
echo "</table>";
?>
我猜我需要一份WARE声明?说“选择胜负>100”?我已经做了大量的选择,但从来没有选择是结束。我还需要将每个结果插入另一个名为rewards的表中您当前的查询
SELECT*FROM users
将为您提供表中的所有数据
要获取wins>=100
的数据,只需添加此条件,即可创建新语句
从wins>=100的用户中选择*
要插入奖励表(考虑到您有用户名、wins等字段),请使用以下命令
从wins>=100的用户中选择*。。这只是一个问题。使用,而你将只是显示所有记录…插入不适合我。你能把它贴上编码吗??不仅仅是文字?你们在奖励表中的字段名是什么?别担心,我现在知道了,只是在中间做了一个简单的插入。你能告诉我你在while循环里写了什么吗??
insert into rewards
(username, wins)
select username, wins
from users
WHERE wins >= 100