我正在编写一个连接到MySQL数据库的简单Java程序。用户可以选择以下任一选项:
1) View the contents of the database
2) Add an entry to the database
3) Remove an entry from the database
问题是,当用户选择删除选项时,会出现一个提示,询问他们想要删除哪一行。
如果有10行,并且用户选择了第5行,则该行将被删除,但当用户选择再次查看数据库内容时,第一个列ID编号将按如下方式运行
1
2
3
4
6
7
8
9
10
我希望在删除第5行后,编号会下移,即go
1
2
3
4
5
6
7
8
我有一个5列的表(列是id、answer、weight、quiz_id和question_id),我想先按question_id排序,然后按weihgt排序,然后根据这种双重排序对id列进行递增编号。在mysql (我使用的是phpmyadmin)中可以吗?
谢谢
类似于:
SELECT
@curRow := @curRow + 1 AS id,
T.Answer, T.Weight, T.Quiz_Id, T.Question_Id
FROM wp_wpss_Answers T
JOIN (SELECT @curRow := 0) r
ORDER BY Questi
如何对mySQL结果进行编号。我尝试使用$_SESSION[],但我无法使用。请帮帮我
<?php
$id=$_POST['id'];
function showmember($id){
$int=$_SESSION['int']+1;
$query = mysql_query("SELECT id,name,sponsorid,node FROM ".memberlogtbl." WHERE locationid='".$id."' ORDER BY join_time DESC LIMI
我使用以下代码从数据库创建了一个页面:
<?php
$sql = "SELECT * FROM `inventory` where `prod_id` = 1"; // manipulate id ok
$qry = mysql_query($sql);
$result=mysql_fetch_array($qry);
// this is code to display picture
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['prod_pi
我有这个链接floors.php?id=building1&floor1
它表现得像这样
flats.php?id=Building1&1
建筑物名称及楼层编号
链接有楼层编号和建筑名称
现在我如何在MySQL查询中连接
$query = "SELECT * FROM floors where buildingname='$id' And
floorno='i want here floor no how can i do this' ORDER BY floorno
如何从mysql数据库中回显随机id号而不重复编号?
这是我的示例代码:
$query = mysql_query("SELECT * FROM store");
$number=mysql_num_rows($query);
for ($count=1; $count<= $number ; $count++)
{
$id = mysql_query ("SELECT id FROM store ORDER BY RAND() LIMIT $number");
$id = mysql_fetch_assoc($id);
$id = $
如何将自动编号插入mysql中的字段id?我的idmember已经是主键,这是我尝试过的代码,请更正它
UPDATE member SET id = Row_number()over ORDER BY idmember
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'over order by idmember' at line 1
我有一个应用程序,它将问题添加到问题行中。但是,当涉及到在数据库中插入值时,我有一个问题。
在我的应用程序中,如果我添加两个问题,则如下所示:
SessionId QuestionId QuestionContent
ABV 1 What is 2+2?
ABV 2 What is 3+3?
但是如果我将这些值添加到数据库中,那么它会像这样插入它:
SessionId QuestionId QuestionContent
ABV 3 What is 2
我有一个包含以下字段的mysql表:
id用户名密码角色
管理员的角色编号为1,普通用户的角色编号为2
<?php
// we must never forget to start the session
session_start();
$errorMessage = '';
if (isset($_POST['username']) && isset($_POST['password'])) {
include 'library/connect.php';
$username
可能重复:
我想对查询结果进行编号。我能用mysql做这个吗?
假设我有以下查询
SELECT id
, application_id
, 3rd_column_to_generate From SemesterApplication
WHERE SemesterApplication.semester.id = 1
ORDER BY SemesterApplication.modified
我需要查询返回第三列,它将保存结果的编号。如果查询返回20个结果,则第3列将返回1到20之间的值。
此查询将用作另一个查询中的子查询。
我有两个mysql和sqlserver数据库,我彼此共享相同的数据,但为了不会有id冲突,我希望每个mysql银行的编号= 2,sqlserver = 1,我希望通过mysql插入表格id,银行编号+订单id。例如:
mysql bank -> 2
auto_incremente cidade id -> 38
saved to cidade table primary key id = 238
所以我写了这段代码:
DELIMITER $
CREATE TRIGGER Tgr_Cidade_Insert AFTER INSERT
ON cidade
FOR EACH ROW
B