Problem Static analysis when importing a large database - mysql

I have a problem with importing a large database. I created a database on PHPMyAdmin on my wamp64 locally and then installed a GLPI with this database. Now that everything is functional I would like to import it on the company's server where I am to set up my GLPI with my database instead of the current one. However I have a problem when I go to the company's PhPMyAdmin I try to import a database but I have an error that tells me""" so I try to zip the file so that it is less heavy or to create the line $cfg['UploadDir'] ='upload'; but when I do that I have this error :
Error
Static analysis :
1 errors found during the analysis.
Unrecognized keyword. (near "ON" at position 25)
SQL query: Modify Modify Modify
SET FOREIGN_KEY_CHECKS = ON;
MySQL replied: Documentation
2006 - MySQL server has gone away
Warning in .\libraries\dbi\DBIMysqli.class.php#261
mysqli_query(): MySQL server has gone away
Backtrace
.\libraries\dbi\DBIMysqli.class.php#261: mysqli_query( object, string
INSERT INTO glpi_crontasklogs (id, crontasks_id,
crontasklogs_id, date, state, elapsed, volume, content)
VALUES (1, 9, 0, \'2019-03-01 15:39:08', 0, 0, 0, 0, 0, \'Run mode:
CLI\'), (2, 9, 1, \'2019-03-01 15:39:08\', 1, 0.0755451, 0, \'Collect
mails from assistance#carpediem.pro
({outlook.office365.com:995/pop/ssl})\n\n\'), (3, 9, 1, \'2019-03-01
15:39:08\', 1, 0.645032, 0, \'Number of messages: available=0,
retrieved=0, refused=0, errors=0, blacklisted=0\n\n\'), (4, 9, 1,
\'2019-03-01 15:39:08\', 2, 1.23802, 0, \'Action completed, no
processing required\'), (7, 9, 0, 0, \'2019-03-01 15:40:18\', 0, 0, 0,
0, \'Run mode: CLI\'), (8, 9, 7, \'2019-03-01 15:40:18\', 1,
0.0849578, 0, \'Mail collection from assistance#carpediem.pro ({outlook.office365.com:995/pop/ssl})\n\n\'), (9, 9, 7, \'2019-03-01
15:40:18\', 1, 1.17437, 0, \'Number of messages: available=0,
retrieved=0, refused=0, errors=0, blacklisted=0\n\'), (10, 9, 7,
\'2019-03-01 15:40:18\', 2, 1.45225, 0, \'Action completed, no
processing required\'), (11, 29, 0, \'2019-03-01 15:40:18\', 0, 0, 0,
0, \'Run mode: CLI\'), (12, 29, 11, \'2019-03-01 15:40:18\', 2,
0.126937, 0, \'Action completed, no processing required\'), (15, 9, 0, 0, \'2019-03-01 15:41:07\', 0, 0, 0, 0, \'Run mode: CLI\'), (16, 9,
15, \'2019-03-01 15:41:07\', 1, 0.0819528, 0, \'Collect mails from
assistance#carpediem.pro ({outlook.office365.com:995/pop/ssl})\n\n\'),
(17, 9, 15, \'2019-03-01 15:41:07\', 1, 0.995655, 0, \'Number of
messages: available=0, retrieved=0, refused=0, errors=0,
blacklisted=0\n\n\'), (18, 9, 15, \'2019-03-01 15:41:07\', 2, 1.05668,
0, \'Action completed, no processing required\'), (21, 9, 0, 0,
\'2019-03-01 15:42:17\', 0, 0, 0, 0, \'Run mode: CLI\'), (22, 9, 21,
\'2019-03-01 15:42:17\', 1, 0.0884838, 0, \'Collect mails from
assistance#carpediem.pro ({outlook.office365.com:995/pop/ssl})\n\n\'),
(23, 9, 21, \'2019-03-01 15:42:17\', 1, 1.15658, 0, \'Number of
messages: available=0, retrieved=0, refused=0, errors=0,
blacklisted=0\n\n\'), (24, 9, 21, \'2019-03-01 15:42:17\', 2, 1.20123,
0, \'Action completed, no processing required\'), (25, 17, 0, 0,
\'2019-03-01 15:42:17\', 0, 0, 0, 0, \'Run mode: CLI\'), (26, 17, 25,
\'2019-03-01 15:42:17\', 2, 0.102944, 0, \'Action completed, no
processing required\'), (31, 9, 0, 0, \'2019-03-01 15:43:05\', 0, 0,
0, 0, \'Run mode: CLI\'), (32, 9, 31, \'2019-03-01 15:43:05\', 1,
0.0800591, 0, \'Collect mails from assistance#carpediem.pro ({outlook.office365.com:995/pop/ssl})\n\n\'), (33, 9, 31, \'2019-03-01
15:43:05\', 1, 1.04019, 0, \'Number of messages: available=0,
retrieved=0, rejected=0, errors=0, blacklisted=0\n\n\'), (34, 9, 31,
\'2019-03-01 15:43:05\', 2, 1.05323, 0, \'Action completed, no
processing required\'), (35, 23, 0, 0, \'2019-03-01 15:43:05\', 0, 0,
0, 0, \'Run mode: CLI\'), (36, 23, 35, \'2019-03-01 15:43:05\', 2,
0.117135, 0, \'Action completed, no processing required'), (39, 9, 0, 0, \'2019-03-01 15:44:16\', 0, 0, 0, 0, \'Run mode: CLI\'), (40, 9,
39, \'2019-03-01 15:44:16\', 1, 0.0911481, 0, \'Collect emails from
assistance#carpediem.pro ({outlook.office365.com:995/pop/ssl})\n\n\'),
(41, 9, 39, \'2019-03-01 15:44:16\', 1, 1.14253, 0, \'Number of
messages: available=0, retrieved=0, refused=0, errors=0,
blacklisted=0\n\n\'), (42, 9, 39, \'2019-03-01 15:44:16\', 2, 1.18234,
0, \'Action completed, no processing required\'), (45, 9, 0, 0,
\'2019-03-01 15:45:03\', 0, 0, 0, 0, \'Run mode: CLI\'), (46, 9, 45,
\'2019-03-01 15:45:03\', 1, 0.053148, 0, \'Collect mails from
assistance#carpediem.pro ({outlook.office365.com:995/pop/ssl})\n\n\'),
(47, 9, 45, \'2019-03-01 15:45:45:03\', 1, 0.933414, 0, \'Number of
messages: available=0, retrieved=0, refused=0, errors=0,
blacklisted=0\n\n\'), (48, 9, 45, \'2019-03-01 15:45:03\', 2,
0.941932, 0, \'Action completed, no processing required\'), (49, 29, 0, \'2019-03-01 15:45:03\', 0, 0, 0, 0, \'Run mod.....
.\libraries\plugins\import\ImportSql.class.php#161:
PMA_importRunQuery( string 'DROP TABLE IF EXISTS glpi_crontasks',
string 'DROP TABLE IF EXISTS glpi_crontasks', boolean false, array,
) .\import.php#641: ImportSql->doImport(array)
Can you help me because I don't know where the problem comes from and I don't know how to fix it

Using phpmyadmin to export and import a large database might be suboptimal.
Use mysqldump command to backup and mysql to restore. There are plenty of examples over the net. Just a head start:
Backup
mysqldump --add-drop-table --complete-insert --extended-insert --quote-names --host=localhost --user=root --password=YOURPASSWORD glpi > c:\glpibackup\glpi_mysqldump.sql
Restore
mysql -u root -p YOURPASSWORD < c:\glpibackup\glpi_mysqldump.sql

Related

how do i rewrite the correct statement for COUNT under this condition

Bring back the count of all the batsmen who have played a certain number of innings only if there are more than one batsman who have played that number of innings. 4 innings – 2 batsmen, 5 innings – 3 batsmen etc.
SELECT COUNT(Innings) AS TotalInnings, COUNT(player) AS Totalplayer
FROM Batting
GROUP BY Player
Player is the field name for the batsmens name. I am kinda stuck on how to write the last lines statement
4 innings – 2 batsmen, 5 innings – 3 batsmen etc
This is the table design
CREATE TABLE Batting (
Player CHAR(25),
CarrerSpan VARCHAR(20),
Matches INT,
Innings INT,
Playing INT,
Runs INT,
HighestScore CHAR(10),
AverageScore NUMERIC,
BallsFaced INT,
StrikeRate NUMERIC,
Hundreds INT,
Fifties INT,
Zeros INT,
Fours INT,
Sixs INT
);
INSERT INTO Batting
VALUES ('JP Duminy', '2007-2018', 77, 71, 22, 1825, '96*', 37.24, 1468, 124.31, 0, 11, 6, 130, 65);
INSERT INTO Batting
VALUES ('AB de Villiers', '2006-2017', 78, 75, 11, 1672, '79*', 26.12, 1237, 135.16, 0, 10, 5, 140, 60);
INSERT INTO Batting
VALUES ('HM Amla', '2009-2018', 41, 41, 5, 1158, '97*', 32.16, 883, 131.14, 0, 7, 2, 133, 23);
INSERT INTO Batting
VALUES ('F du Plessis', '2012-2017', 36, 36, 6, 1129, 119, 37.63, 849, 132.97, 1, 7, 0, 102, 35);
INSERT INTO Batting
VALUES('DA Miller', '2010-2018', 58, 51, 15, 1043, '101*', 28.97, 745, 140.00, 1, 1, 0, 71, 46);
INSERT INTO Batting
VALUES('GC Smith', '2005-2011', 33, 33, 2, 982, '89*', 31.67, 770, 127.53, 0, 5, 1, 123, 26);
INSERT INTO Batting
VALUES('Q de Kock','2012-2018', 32, 32, 4, 821, 59, 29.32, 637, 128.88, 0, 2, 3, 97, 24);
INSERT INTO Batting
VALUES('JH Kallis', '2005-2012', 25, 23, 4, 666, 73, 35.05, 558, 119.35, 0, 5, 0, 56, 20);
INSERT INTO Batting
VALUES('JA Morkel', '2005-2015', 50, 38, 11, 572, 43, 21.18, 402, 142.28, 0, 0, 1, 29, 39);
INSERT INTO Batting
VALUES('F Behardien', '2012-2018', 37, 29, 13, 515, '64*', 32.18, 402, 128.10, 0, 1, 1, 37, 16);
INSERT INTO Batting
VALUES('HH Gibbs', '2005-2010', 23, 23, 1, 400, '90*', 18.18, 318, 125.78, 0, 3, 4, 45, 12);
INSERT INTO Batting
VALUES('RR Rossouw', '2014-2016', 15, 14, 3, 327, 78, 29.72, 237, 137.97, 0, 2, 2, 29, 12);
INSERT INTO Batting
VALUES('LE Bosman', '2006-2010', 14, 14, 1, 323, 94, 24.84, 219, 147.48, 0, 3, 2, 27, 20);
INSERT INTO Batting
VALUES('RR Hendricks', '2014-2018', 13, 13, 0, 294, 70, 22.61, 262, 112.21, 0, 1, 2, 33, 3);
INSERT INTO Batting
VALUES('MV Boucher', '2005-2010', 25, 21, 6, 268, '36*', 17.86, 275, 97.45, 0, 0, 0, 22, 2);
INSERT INTO Batting
VALUES('RE Levi', '2012-2012', 13 ,13, 2, 236, '117*', 21.45, 167, 141.31, 1, 1, 3, 20, 15);
INSERT INTO Batting
VALUES('MN van Wyk', '2007-2015', 8, 7, 1, 225, '114*', 37.50, 157, 143.31, 1, 1, 0, 19, 14);
INSERT INTO Batting
VALUES('CA Ingram', '2010-2012', 9, 9, 1, 210, 78, 26.25, 162, 129.62, 0, 1, 1, 23, 7);
INSERT INTO Batting
VALUES('JM Kemp', '2005-2007', 8, 7, 3, 203, '89*', 50.75, 160, 126.87, 0, 1, 0, 17, 10);
INSERT INTO Batting
VALUES('J Botha', '2006-2012', 40, 0, 9, 201, 34, 18.27, 165, 121.81, 0, 0, 1, 15, 9);
INSERT INTO Batting
VALUES('H Davids', '2012-2013', 9, 9, 0, 161, 68, 17.88, 134, 120.14, 0, 2, 2, 18, 4);
INSERT INTO Batting
VALUES('JL Ontong', '2008-2015', 14, 10, 0, 158, 48, 15.80, 109, 144.95, 0, 0, 1, 6, 11);
INSERT INTO Batting
VALUES('JT Smuts', '2017-2018', 8, 8, 0, 126, 45, 15.75, 114, 110.52, 0, 0, 1, 14, 5);
INSERT INTO Batting
VALUES('RJ Peterson', '2006-2014', 21, 12, 4, 124, 34, 15.50, 113, 109.73, 0, 0, 1, 13, 2);
INSERT INTO Batting
VALUES('WD Parnell', '2009-2017', 40, 13, 9, 114, '29*', 28.50, 96, 118.75, 0, 0, 0, 10, 3);
INSERT INTO Batting
VALUES( 'H Klaasen', '2018-2018', 4, 4, 0, 110, '69', 27.50, 64, 171.87, 0, 1, 0, 5, 9);
INSERT INTO Batting
VALUES( 'M Mosehle', '2017-2017', 7, 6, 1, 105, '36', 21.00, 65, 161.53, 0, 0, 0, 6, 9);
INSERT INTO Batting
VALUES( 'D Wiese', '2013-2016', 20, 11, 4, 92, '28', 13.14, 75, 122.66, 0, 0, 1, 4, 3);
INSERT INTO Batting
VALUES( 'SM Pollock', '2005-2008', 12, 9, 2, 86, '36*', 12.28, 70, 122.85, 0, 0, 3, 4, 4);
INSERT INTO Batting
VALUES( 'CH Morris', '2012-2018', 17, 10, 3, 77, '17*', 11.00, 70, 110.00, 0, 0, 2, 7, 2);
INSERT INTO Batting
VALUES( 'RE van der Merwe', '2009-2010', 13, 6, 3, 57, '48', 19.00, 50, 114.00, 0, 0, 1, 2, 4);
INSERT INTO Batting
VALUES( 'C Jonker', '2018-2018', 1, 1, 0, 49, '49', 49.00, 24, 204.16, 0, 0, 0, 5, 2);
INSERT INTO Batting
VALUES( 'HG Kuhn', '2009-2017', 7, 6, 2, 49, '29', 12.25, 42, 116.66, 0, 0, 0, 3, 2);
INSERT INTO Batting
VALUES( 'JJ van der Wath', '2006-2007', 8, 4, 1, 46, '21', 15.33, 39, 117.94, 0, 0, 0, 3, 1);
INSERT INTO Batting
I think this could be the solution to your problem:
Query1
SELECT Innings,
COUNT(player) AS Totalplayer
FROM Batting
GROUP BY Innings
HAVING COUNT(player) > 1;
OR
Query2
SELECT Innings,
COUNT(player) AS Totalplayer
FROM Batting
GROUP BY Innings
HAVING COUNT(Innings) > 1;
Sample Output :
Innings
Totalplayer
4
2
6
3
7
2
9
3
10
2
13
3
14
2
23
2
View on DB Fiddle
Well you can save the number of rows for which the Innings column has certain value. You can save this number in a temporary table and then query the table. See following SQL:
CREATE TEMPORARY TABLE BatsmenCount (SELECT count(*) as total FROM Batting WHERE Innings=71);
SELECT * FROM BatsmenCount WHERE total > 1;
This query will return the number of batsmen that have played 71 innings and save the result in a temporary table. Next this number is fetched using SELECT query. If the query returns no results, then the number of batsmen that have played 71 innings is 1 or less. If the query returns a result, then this result is the number of batsmen that have played 71 innings.
See the SQL code on dbfiddle.

Whats wrong in my code ? 1064 check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line

I have a problem in my code
I don't know where the error in my code and I think my code is fine (maybe)
plase help me
this is my code :
CREATE TABLE IF NOT EXISTS `dt_training` (
`id_training` int(11) NOT NULL AUTO_INCREMENT,
`tanggal` date NOT NULL,
`pm25` int(1) DEFAULT NULL,
`curahHujan` int(1) DEFAULT NULL,
`kelembaban` int(1) DEFAULT NULL,
`kecepatanAngin` int(1) DEFAULT NULL,
`RESULT` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id_training`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=476 ;
INSERT INTO `dt_training` (`id_training`, `tanggal`, `pm25`, `curahHujan`, `kelembaban`,
`kecepatanAngin`, `RESULT`) VALUES
(1, '2/1/2019', 37.69416376, 1, 78, 2, 0),
(2, '2/2/2019', 27.61848739, 2.3, 70, 3, 0),
(3, '2/8/2019', 34.82260521, 0, 79, 2, 0),
(4, '2/9/2019', 40.56758941, 1.3, 79, 2, 0),
(5, '2/10/2019', 24.05520774, 30.5, 84, 2, 0),
.
.
.
(450, '8/3/2020', 43.53877095, 0, 74, 2, 0),
(451, '8/4/2020', 59.05010846, 0,79, 1, 0),
(452, '8/5/2020', 106.6554527, 14.6, 78, 1, 0),
(453, '8/6/2020', 67.41181118, 0, 75, 2, 0),
(454, '8/7/2020', 62.0547619, 0, 76, 2, 0),
(456, '8/8/2020', 87.904, 0, 76, 2, 0),
(457, '8/9/2020', 69.39713576, 0, 74, 2, 0),
(458, '8/10/2020', 77.89735294, 0, 74, 2, 0),
(459, '8/11/2020', 94.91111111, 0, 78, 0, 0),
(460, '8/12/2020', 58.48239865, 20, 83, 1, 0),
(461, '8/13/2020', 16.5097891, 0, 87, 1, 0),
(462, '8/14/2020', 15.48111111, 2.2, 84, 1, 0),
(463, '8/15/2020', 14.62266776, 3.6, 80, 2, 0),
(464, '8/16/2020', 12.87, 0.8, 79, 2, 0),
(465, '8/17/2020', 10.55883162, 0.4, 75, 2, 0),
(467, '8/18/2020', 14.51629568, 0, 78,1 , 0),
(468, '8/19/2020', 7.316003289, 0, 74, 3, 0),
(469, '8/20/2020', 9.824069767, 0, 70, 2, 0),
(470, '8/26/2020', 0, 0, 58, 4, 0),
(471, '8/27/2020', 0, 0, 63, 3, 0),
(472, '8/28/2020', 0, 0, 67, 3, 0),
(473, '8/29/2020', 0, 0, 74, 2, 0),
(474, '8/30/2020', 0, 0, 70, 2, 0),
(475, '8/31/2020', 0, 0, 66 ,2 , 0);
and MYSQL said :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB
server version for the right syntax to use near '' at line 469
... 1064 ... near ''
That usually means that that is an unclosed parenthesis, quote, or other syntax punctuation. (I don't happen to see such in the snippet you provided; check the rest of the text.)
Other issues. Use a 1-byte TINYINT instead a 4-byte INT for flags.
'2/1/2019' is not compatible with DATE datatype. You could use a str_to_date() to fix it as you insert the data, or you could change to '2019/02/01' (Or is it '2019/01/02'??)

how to reduce line space for <pre>

reproducible code
Hello, I used the following code in markdown
<pre><span style="color:blue">Text = ' Sooo SAD I will miss you here in San Diego!!!'</span>, <span style="color:blue">Selected Text='Sooo SAD'</span>, <span style="color:blue">Sentiment = 'negative'</span></pre>
<pre>tokens =</pre>
<pre>input_ids = [0, 2430, 98, 3036, 5074, 939, 40, 2649, 47, 259, 11, 15610, 1597, 2977, 16506, 2, 1, 1...1]</pre>
<pre>attention_masks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0]</pre>
<pre>start_tokens = [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0]</pre>
<pre>end_tokens = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0]</pre>
<pre>Edit Text = ' Sooo SAD I will miss you here in San Diego!!!' (len=46), Edit Seletected Text='Sooo SAD' (len=8)</pre>
<pre>char = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0] (len=46, num_1=9)</pre>
<pre>offset = [(0, 3), (3, 5), (5, 9), (9, 11), (11, 16), (16, 21), (21, 25), (25, 30), (30, 33), (33, 37), (37, 41), (41, 43), (43, 46)]</pre>
undesired effect
and generate the following effect
But the too wide line space makes the effect is kind of ugly. Do you know how to redue the line space?
Tried method
I tried this method
<pre style='display:inline'>tokens =</pre> <br>
<pre>input_ids = [0, 2430, 98, 3036, 5074, 939, 40, 2649, 47, 259, 11, 15610, 1597, 2977, 16506, 2, 1, 1...1]</pre>
But it only works for one line, if I want to apply to other lines such as this
<pre style='display:inline'>tokens =</pre> <br>
<pre style='display:inline'>input_ids = [0, 2430, 98, 3036, 5074, 939, 40, 2649, 47, 259, 11, 15610, 1597, 2977, 16506, 2, 1, 1...1]</pre> <br>
<pre>attention_masks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0]</pre>
it would cover part of line content
Question
How to reduce the line space? Thank you
You could use css display and line-height properties on the pre elements and adjust the line-height you want.
pre {
display: inline;
line-height: 0.8em;
}
<pre><span style="color:blue">Text = ' Sooo SAD I will miss you here in San Diego!!!'</span>, <span style="color:blue">Selected Text='Sooo SAD'</span>, <span style="color:blue">Sentiment = 'negative'</span></pre>
<pre>tokens =</pre>
<pre>input_ids = [0, 2430, 98, 3036, 5074, 939, 40, 2649, 47, 259, 11, 15610, 1597, 2977, 16506, 2, 1, 1...1]</pre>
<pre>attention_masks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0]</pre>
<pre>start_tokens = [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0]</pre>
<pre>end_tokens = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0]</pre>
<pre>Edit Text = ' Sooo SAD I will miss you here in San Diego!!!' (len=46), Edit Seletected Text='Sooo SAD' (len=8)</pre>
<pre>char = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0] (len=46, num_1=9)</pre>
<pre>offset = [(0, 3), (3, 5), (5, 9), (9, 11), (11, 16), (16, 21), (21, 25), (25, 30), (30, 33), (33, 37), (37, 41), (41, 43), (43, 46)]</pre>
Or reset the default margin.
You can use margin: 0 (or any other value) for pre in CSS:
pre {
margin: 0;
}
<pre><span style="color:blue">Text = ' Sooo SAD I will miss you here in San Diego!!!'</span>, <span style="color:blue">Selected Text='Sooo SAD'</span>, <span style="color:blue">Sentiment = 'negative'</span></pre>
<pre>tokens =</pre>
<pre>input_ids = [0, 2430, 98, 3036, 5074, 939, 40, 2649, 47, 259, 11, 15610, 1597, 2977, 16506, 2, 1, 1...1]</pre>
<pre>attention_masks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0]</pre>
<pre>start_tokens = [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0]</pre>
<pre>end_tokens = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0]</pre>
<pre>Edit Text = ' Sooo SAD I will miss you here in San Diego!!!' (len=46), Edit Seletected Text='Sooo SAD' (len=8)</pre>
<pre>char = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0...0] (len=46, num_1=9)</pre>
<pre>offset = [(0, 3), (3, 5), (5, 9), (9, 11), (11, 16), (16, 21), (21, 25), (25, 30), (30, 33), (33, 37), (37, 41), (41, 43), (43, 46)]</pre>

MYSQL- Substract two colums and get the result

I am trying to write a query wherein it should count the number of students and tell me the remaining seats available in a vehicle.
Have managaed to identify which student is associated to which bus but getting stuck to find the seat remaining
Below is data :
vehnum route seats student id
23 2 45 2345
33 3 46 6789
Below is the query :
SELECT deveh.vehicle_reg_no AS vehnum
, veh.route_code AS route
, deveh.seating_capacity AS vehseat
, class.fk_stu_id
FROM tbl_stu_class AS class
JOIN tbl_stu_route AS route
ON route.fk_stu_cls_id = class.pk_stu_cls_id
JOIN list_routes AS veh
ON route.fk_route_id = veh.pk_route_id
JOIN list_vehicles AS deveh
ON deveh.pk_vehicle_id = veh.fk_vehicle_id
WHERE class.fk_year_id = 62
AND class.current_yr = 'Y'
Added sample data :
INSERT INTO `list_vehicles` (`pk_vehicle_id`, `vehicle_reg_no`, `vehicle_type`, `regd_owner_name`, `seating_capacity`, `brand_model`, `type_of_body`, `reg_address`, `fuel_type`, `chasis_no`, `reg_authority`, `engine_no`, `color`, `reg_date`, `reg_valid_date`, `month_yr_mfg`, `fk_user_id`, `timestamp`) VALUES
(46, 'J58987', 'Bus', 'M', 30, 'VOlvo', 'Steel', 'FBD', 'Petrol', '565', 'M1', '5689', 'blue', '2016-10-02', '2016-10-02', '2014-12-31', 1, '2018-07-11 18:01:06'),
(53, 'J1234', 'Bus', 'der', 45, 'Volvo', 'Metal', 'Indirapuram', 'Petrol', '123456', 'det', '2365', 'blue', '2010-12-12', '2020-12-12', '2009-12-11', 1, '2018-07-12 06:54:50'),
(54, 'J1234er', 'Van', 'der', 46, 'Volvo', 'Metal', 'Indirapuram', 'Petrol', '12345634', 'det', '236534', 'blue', '2020-02-03', '2020-02-03', '2008-11-11', 1, '2018-07-12 06:57:59');
INSERT INTO `tbl_stu_class` (`pk_stu_cls_id`, `fk_stu_id`, `fk_year_id`, `fk_class_id`, `fk_section_id`, `current_yr`, `fk_user_id`, `timestamp`) VALUES
(1, 56, 50, 22, 10, 'N', 1, '2018-06-08 06:57:34'),
(3, 123, 50, 24, 7, 'N', 1, '2018-06-12 07:54:46'),
(4, 126, 50, 24, 7, 'N', 56, '2018-06-12 07:54:46'),
(5, 123, 52, 25, 7, 'Y', 1, '2018-06-12 17:30:32'),
(6, 126, 52, 25, 7, 'Y', 1, '2018-06-12 17:30:32'),
(7, 132, 50, 22, 9, 'Y', 1, '2018-06-24 10:27:57'),
(8, 133, 51, 23, NULL, 'Y', 1, '2018-06-24 18:22:33'),
(10, 127, 51, 23, NULL, 'Y', 0, '2018-07-11 17:47:05'),
(11, 134, 62, 22, NULL, 'Y', 0, '2018-07-13 08:11:16'),
(12, 135, 62, 21, 7, 'Y', 1, '2018-07-13 11:12:08'),
(13, 136, 62, 21, 9, 'Y', 1, '2018-07-13 14:59:04');

Pls suggest me an example for dotchart's hover functionality using graphael

I am trying to create a dot chart(bubble chart) using gRaphael. But their documentation is not so clear on how to add hover effects when the user hovers on the dots.
Could any one pls suggest me some examples or give some help tips on the same.
Thanx in advance.
you have to use aDotChart.hoverDot() for registering a "dot hover listener". The following is the source code of example http://cancerbero.vacau.com/gwt/graphael4gwtGallery/?test=dot1 that do what you mention. It is Java code not javascript! but i think it can help you to make an idea of the javascript code:
double[] xs = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
double[] ys = {7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double[] data = {294, 300, 204, 255, 348, 383, 334, 217, 114, 33, 44, 26, 41, 39,
52, 17, 13, 2, 0, 2, 5, 6, 64, 153, 294, 313, 195, 280, 365, 392, 340, 184,
87, 35, 43, 55, 53, 79, 49, 19, 6, 1, 0, 1, 1, 10, 50, 181, 246, 246, 220,
249, 355, 373, 332, 233, 85, 54, 28, 33, 45, 72, 54, 28, 5, 5, 0, 1, 2, 3,
58, 167, 206, 245, 194, 207, 334, 290, 261, 160, 61, 28, 11, 26, 33, 46, 36,
5, 6, 0, 0, 0, 0, 0, 0, 9, 9, 10, 7, 10, 14, 3, 3, 7, 0, 3, 4, 4, 6, 28, 24,
3, 5, 0, 0, 0, 0, 0, 0, 4, 3, 4, 4, 3, 4, 13, 10, 7, 2, 3, 6, 1, 9, 33, 32, 6,
2, 1, 3, 0, 0, 4, 40, 128, 212, 263, 202, 248, 307, 306, 284, 222, 79, 39, 26,
33, 40, 61, 54, 17, 3, 0, 0, 0, 3, 7, 70, 199};
String[] axisy = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
String[] axisx = {"12am", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12pm", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"};
DotOpts opts = new DotOpts();
opts.setSymbol("o");
opts.setMax(10);
opts.setHeat(true);
opts.setAxis("0 0 1 1");
opts.setAxisxlabels(axisx);
opts.setAxisylabels(axisy);
final DotChart c1 = getGPaper().dotchart(10, 10, 620, 260, xs, ys, data, opts);
c1.hoverDot(new DotHoverListener() {
#Override
public void hoverOut(DotContext ctx) {
if(tag!=null)
tag.remove();
}
#Override
public void hoverIn(DotContext ctx) {
tag = (GShape) getGPaper().tag(ctx.getX(), ctx.getY(), ctx.getValue()+"", 0, ctx.getR()+2).
insertBefore(ctx).show();
}
});
Thanks for your reply cancerbero.
Here is my java script solution,
dotChart.hover(function(){//onmouseover
dotChart.covers = r.set();
dotChart.covers.push(r.tag(this.x, this.y, this.value , 0, 10).insertBefore(this));
}, function(){//onmouseout
if(dotChart.covers!=null){
dotChart.covers.remove();
}
});
This has worked fine :)