mysql-variables

    0熱度

    1回答

    從來就搜索了很多,但我不能弄清楚如何做到這一點,如果it's可能...... 我有這個表: CREATE TABLE bilanci ( id int AUTO_INCREMENT NOT NULL, medicoid int NOT NULL, `1` int NOT NULL DEFAULT 0, `2` int NOT NULL DE

    -1熱度

    1回答

    讓我們假設這個模式: CREATE TABLE test ( test_Id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, user_Id INT NOT NULL, date DATE, result VARCHAR(255) NOT NULL, ) engine=innodb; 我的目標是拿起最後5個結果最高爲每個不同的USER_ID,有序從最

    1熱度

    2回答

    所以我發現這個代碼片斷在SO上。它基本上僞造了MySQL的「row_number()」函數。它執行得非常快,我喜歡和需要,但我無法在最後的where子句中加上。 select @i:[email protected]+1 as iterator, t.* from big_table as t, (select @i:=0) as foo 在where iterator

    0熱度

    1回答

    我努力以正確的方式編寫查詢。雖然它的工作我給出的錯誤: A new statement was found but no delimiter between it and the previous one (near select) 很顯然,我仍然可以用這個錯誤,但#1的工作。我不特別喜歡'哈克'的方法和#2。這導致在進一步下線試圖運行查詢的問題。 來自Google Research,它表明錯誤可

    3熱度

    1回答

    我想結合2個不同列的條件來查詢。這是我的原始查詢。你可以在sqlfiddle.com中測試它。 -- creating database first for test data create table attendance(Id int, DateTime datetime, Door char(20)); INSERT INTO attendance VALUES ( 1, '2016-

    0熱度

    1回答

    在下面給出的結果集,其中有2個獨立用戶(ID),並可能有更多這樣的用戶走出查詢: 這裏是多連接查詢: select id, name, col1Code, col2Code, col2Value from users_table UT join col1_table C1T on UT.id = C1T.user_ID_FK join col2_tab

    2熱度

    1回答

    我需要基於build_steps的MAX值創建排名列,其中每個不同的part_id都與order_id關聯爲那part_id。無論何時迭代新的order_id,秩應該重新開始。 我有以下小提琴,但它沒有正確創建排名。 http://sqlfiddle.com/#!9/63d47/29 下面是我的查詢 SET @current_rank = 0; SET @prevOrder = null; S

    0熱度

    2回答

    您好我正在創建一個日期爲列名稱的表。 我使用此代碼列添加到表: DROP PROCEDURE IF EXISTS filldates; DELIMITER | CREATE PROCEDURE filldates(dateStart DATE, dateEnd DATE) BEGIN WHILE dateStart <= dateEnd DO ALTER TABLE da

    0熱度

    1回答

    我有兩個表。我想根據table2中的同一行索引更新table1中的一行。這些ID不匹配,但是表2中的ID與行索引匹配。表2中總是會有更多的數據,但我不在乎是否錯過了額外的行。 我如何在mysql UPDATE語句中實現這個功能? table 1 ______________ table 2 _____________ Row number | id | value | Row nu

    0熱度

    3回答

    ,所以我有這樣的表中的數據排名: id total group_id 1897 738 1 2489 716 2 2325 715 3 1788 702 2 1707 699 3 2400 688 3 2668 682 2 1373 666 1 1494 666 1 1564 660 1 2699 659 1 1307 648