I'm building a website by opencart2.2.
I have installed a module on my website with opencart2.2.
This module is inculded a sql file as following code.
Now I want to uninstall the module, but I don't know how to uninstall the sql seeting from the database.
Could you help me to build a unistall code?
I will appriciate your help.
enter code here
-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Dec 04, 2013 at 07:47 AM
-- Server version: 5.5.27
-- PHP Version: 5.4.7
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `uraaw347_opencart`
--
-- --------------------------------------------------------
--
-- Table structure for table `oc_footerlink`
--
CREATE TABLE IF NOT EXISTS `oc_footerlink` (
`footerlink_id` int(11) NOT NULL AUTO_INCREMENT,
`link` varchar(255) NOT NULL,
`selectheading` varchar(255) NOT NULL DEFAULT '0',
`status` tinyint(1) NOT NULL DEFAULT '1',
`sort_order` int(11) NOT NULL,
PRIMARY KEY (`footerlink_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;
--
-- Dumping data for table `oc_footerlink`
--
INSERT INTO `oc_footerlink` (`footerlink_id`, `link`, `selectheading`, `status`, `sort_order`) VALUES
(22, 'index.php?route=information/information&information_id=4', '9', 1, 0),
(2, '', '4', 1, 0),
(3, '', '4', 1, 0),
(4, '', '4', 1, 0),
(5, '', '4', 1, 0),
(6, '', '4', 1, 0),
(7, 'sdf', '5', 1, 0),
(8, '', '4', 1, 0),
(24, 'index.php?route=common/home', '12', 1, 0),
(25, 'index.php?route=information/contact', '12', 1, 0),
(23, '#', '9', 1, 1),
(26, '#', '11', 1, 0),
(27, '#', '9', 1, 0);
-- --------------------------------------------------------
--
-- Table structure for table `oc_footerlink_description`
--
CREATE TABLE IF NOT EXISTS `oc_footerlink_description` (
`footerlink_id` int(11) NOT NULL,
`language_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `oc_footerlink_description`
--
INSERT INTO `oc_footerlink_description` (`footerlink_id`, `language_id`, `title`) VALUES
(23, 1, 'FAQ'),
(22, 1, 'About'),
(24, 1, 'demo'),
(25, 1, 'demo2'),
(26, 1, 'demo3'),
(27, 1, 'demo4');
-- --------------------------------------------------------
--
-- Table structure for table `oc_footertitle`
--
CREATE TABLE IF NOT EXISTS `oc_footertitle` (
`footertitle_id` int(11) NOT NULL AUTO_INCREMENT,
`status` tinyint(1) NOT NULL DEFAULT '1',
`sort_order` int(11) NOT NULL,
PRIMARY KEY (`footertitle_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `oc_footertitle`
--
INSERT INTO `oc_footertitle` (`footertitle_id`, `status`, `sort_order`) VALUES
(10, 1, 1),
(11, 1, 2),
(9, 1, 0),
(12, 1, 4);
-- --------------------------------------------------------
--
-- Table structure for table `oc_footertitle_description`
--
CREATE TABLE IF NOT EXISTS `oc_footertitle_description` (
`footertitle_id` int(11) NOT NULL,
`language_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
PRIMARY KEY (`footertitle_id`,`language_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `oc_footertitle_description`
--
INSERT INTO `oc_footertitle_description` (`footertitle_id`, `language_id`, `title`) VALUES
(12, 1, 'Custmomer Service'),
(11, 1, 'Health Food'),
(9, 1, 'Our Company'),
(10, 1, 'Customize');
/*!40101 SET CHARACTER_SET_CLIENT=#OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=#OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=#OLD_COLLATION_CONNECTION */;
simplest way via phpmyadmin. Just find this tables:
oc_footertitle
oc_footerlink_description
oc_footertitle
oc_footertitle_description
and drop it.
oc_footertitle
oc_footerlink_description
oc_footertitle
oc_footertitle_descriptione
please simply find these tables in your db and drop them make sure to backup database before doing anything if unsure
Related
Static analysis:
2 errors were found during analysis.
An opening bracket followed by a set of values was expected. (near "ALTER" at position 571)
Unexpected token. (near "ALTER" at position 571)
MySQL said: Documentation
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 ''eyecolor', 'flag') VALUES
(1, 'Иван', 'Петров', '173', 'Кафяв', ' at line 5
-- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: 7 апр 2020 в 09:51
-- Версия на сървъра: 10.4.11-MariaDB
-- PHP Version: 7.4.3
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `personbase`
--
-- --------------------------------------------------------
--
-- Структура на таблица `persons`
--
CREATE TABLE `persons` (
`id` int(11) NOT NULL,
`name` varchar(25) COLLATE utf32_bin NOT NULL,
`family` varchar(25) COLLATE utf32_bin NOT NULL,
`height` varchar(30) COLLATE utf32_bin NOT NULL,
`haircolor` varchar(30) COLLATE utf32_bin NOT NULL,
`eyecolor` varchar(30) COLLATE utf32_bin NOT NULL,
`flag` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf32 COLLATE=utf32_bin;
--
-- Схема на данните от таблица `persons`
--
INSERT INTO `persons` (`id`, `name`, `family`, `height`, `haircolor`, 'eyecolor', 'flag') VALUES
(1, 'Иван', 'Петров', '173', 'Кафяв', 'Син', 0),
(2, 'Стефан', 'Петров', '173', 'Кафяв', 'Син', 1),
(3, 'Калин', 'Петров', '173', 'Кафяв', 'Син', 0),
(4, 'Димитър', 'Петров', '173', 'Кафяв', 'Син', 1),
(5, 'Алекс', 'Петров', '173', 'Кафяв', 'Син', 0),
(6, 'Иван', 'Петров', '173', 'Кафяв', 'Син', 1),
(7, 'Мартин', 'Петров', '173', 'Кафяв', 'Син', 0),
--
-- Indexes for dumped tables
--
--
-- Indexes for table `persons`
--
ALTER TABLE `persons`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `persons`
--
ALTER TABLE `persons`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=#OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=#OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=#OLD_COLLATION_CONNECTION */;
I m not sure , why I am getting the below error, while executing the below SQL in my SQL Editor for DB2 (DB2 for z/OS)
DECLARE GLOBAL TEMPORARY TABLE SESSION.VTI_GUI_TMP (
ENCRP_PRC_RL_ID INTEGER NOT NULL,
PROC_SYS_CD VARCHAR(10) NOT NULL,
VER_KEY_SET_CD VARCHAR(10) NOT NULL,
TRNSLT_TP_CD VARCHAR(10) NOT NULL,
SET_INDEX_NUM VARCHAR(10) NOT NULL,
SET_MDK_DKI_NUM VARCHAR(10) NOT NULL,
PACKET_NUM INTEGER NOT NULL ) ON COMMIT PRESERVE ROWS;
INSERT INTO SESSION.VTI_GUI_TMP (
ENCRP_PRC_RL_ID, PROC_SYS_CD, VER_KEY_SET_CD, TRNSLT_TP_CD,
SET_INDEX_NUM, SET_MDK_DKI_NUM, PACKET_NUM
)
VALUES (500159, 'DB', 'MDK', '0', '1', '001', 766473)
UNION ALL
(500151, 'DB', 'MDK', '0', '2', '002', 766473);
select * from SESSION.VTI_GUI_TMP;
DROP TABLE SESSION.VTI_GUI_TMP;
I am getting the below error , while executing the above the SQL
ILLEGAL USE OF KEYWORD UNION. TOKEN FOR NOT ATOMIC WAS EXPECTED. SQLCODE=-199, SQLSTATE=42601, DRIVER=3.63.75 SQL Code: -199, SQL State: 42601
Error occurred in:
INSERT INTO SESSION.VTI_GUI_TMP (ENCRP_PRC_RL_ID, PROC_SYS_CD, VER_KEY_SET_CD, TRNSLT_TP_CD, SET_INDEX_NUM, SET_MDK_DKI_NUM, PACKET_NUM) VALUES(500159, 'DB', 'MDK', '0', '1', '001', 766473) UNION ALL(500151, 'DB', 'MDK', '0', '2', '002', 766473)
How can we fix the above error ? I dont want to use the SELECT statement along with UNION ALL to fix. Is there any way to make this work.
I am using the below DB2 version
SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1
-----------
DSN11015
What am I doing wrong?
Can't you use two separate INSERT statements? For example:
DECLARE GLOBAL TEMPORARY TABLE SESSION.VTI_GUI_TMP (
ENCRP_PRC_RL_ID INTEGER NOT NULL,
PROC_SYS_CD VARCHAR(10) NOT NULL,
VER_KEY_SET_CD VARCHAR(10) NOT NULL,
TRNSLT_TP_CD VARCHAR(10) NOT NULL,
SET_INDEX_NUM VARCHAR(10) NOT NULL,
SET_MDK_DKI_NUM VARCHAR(10) NOT NULL,
PACKET_NUM INTEGER NOT NULL
) ON COMMIT PRESERVE ROWS;
INSERT INTO SESSION.VTI_GUI_TMP (
ENCRP_PRC_RL_ID, PROC_SYS_CD, VER_KEY_SET_CD, TRNSLT_TP_CD,
SET_INDEX_NUM, SET_MDK_DKI_NUM, PACKET_NUM
) VALUES (500159, 'DB', 'MDK', '0', '1', '001', 766473)
INSERT INTO SESSION.VTI_GUI_TMP (
ENCRP_PRC_RL_ID, PROC_SYS_CD, VER_KEY_SET_CD, TRNSLT_TP_CD,
SET_INDEX_NUM, SET_MDK_DKI_NUM, PACKET_NUM
) VALUES (500151, 'DB', 'MDK', '0', '2', '002', 766473);
Or maybe:
INSERT INTO SESSION.VTI_GUI_TMP (
ENCRP_PRC_RL_ID, PROC_SYS_CD, VER_KEY_SET_CD, TRNSLT_TP_CD,
SET_INDEX_NUM, SET_MDK_DKI_NUM, PACKET_NUM)
SELECT 500159, 'DB', 'MDK', '0', '1', '001', 766473 FROM sysibm.sysdummy1
UNION ALL
SELECT 500151, 'DB', 'MDK', '0', '2', '002', 766473 FROM sysibm.sysdummy1
Since the syntax was not accurate, Db2 attempted to provide guidance on what might be expected. In the example SQL, Db2 thought you might be wanting to use a multiple-row-insert where NOT ATOMIC is expected. For the INSERT statement, the VALUES clause supports an expression, DEFAULT, and NULL (https://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/sqlref/src/tpc/db2z_sql_insert.html). An INSERT with VALUES using UNION ALL is currently not supported. The two examples provided by #The Impaler appear to be valid syntax: 1) INSERT with VALUES using valid expressions and 2) INSERT with fullselect.
CREATE TABLE collections
(
id INTEGER IDENTITY(1,1) PRIMARY KEY,
name VARCHAR(50) NOT NULL
);
CREATE TABLE posts
(
id INTEGER IDENTITY(1, 1) PRIMARY KEY,
title VARCHAR(50) NOT NULL,
image_URL VARCHAR(120) NOT NULL,
author_id INTEGER NOT NULL,
collection_id INTEGER,
FOREIGN KEY(author_id) REFERENCES users(id),
FOREIGN KEY(collection_id) REFERENCES collections(id)
);
INSERT INTO collections (name)
VALUES ('Travel'), ('Nature'), ('Great Outdoors');
INSERT INTO posts (title, image_url, author_id, collection_id)
VALUES ('White Mountains', 'cloudinary.com/snp/balhwpq.jpg', 3, NULL),
('My new car!', 'cloudinary.com/snp/qpcnalpw.jpg', 1, NULL),
('Great weekend for camping', 'cloudinary.com/snp/nmclapa.png', 5, 3),
('Train Ride to France', 'cloudinary.com/snp/rjaptpalw.jpg', 4, 1),
('Small Town in Italy', 'cloudinary.com/snp/aqypqoua.jpg', 4, 1),
('Nice Day At The Air Show', 'cloudinary.com/snp/aswpqlsaq.jpg', 7, NULL),
('Barcelona Beach', 'cloudinary.com/snp/quapwnla.jpg', 9, NULL),
('Gorgeous City of Prague', 'cloudinary.com/snp/anvmapw.png', 3, NULL),
('Nothing like fresh Seafood!', 'cloudinary.com/snp/uqnqhapla.jpg', 8, 4),
('Bought a new Swiss army knife', 'cloudinary.com/snp/qanvpauaq.jpg', 6, NULL),
('Delicious meal in Boston', 'cloudinary.com/snp/malvpqlsa.jpg', 10, NULL),
('Swimming at Ursa Beach', 'cloudinary.com/snp/poqlanoqlav.jpg', 12, NULL),
('Chilly day in Norway', 'cloudinary.com/snp/vqwlnqposp.jpg', 11, NULL),
('Hiking through beautiful Vermont!', 'cloudinary.com/snp/qpoplnalqi.jpg', 5, 3);
Every time I try executing this, it completes the table creation and the first two insert statements and then I get an error
The INSERT statement conflicted with the FOREIGN KEY constraint
I believe the problem is that in the posts table Insert statement I'm setting some of the collection_id values to NULL which is causing the error. I never said that this column couldn't be NULL, so what's the problem?
I made this code for SQL Server to select how many times the rider "AsdoVolante" came first in the first semester of 2017. But it does not work. What could be wrong?
SELECT P.Data, Nm.Nome, epp.PosicaoFinal
FROM Prova P, Piloto Nm, EquipaParticipaProva epp
WHERE epp.PosicaoFinal = (SELECT PosicaoFinal FROM EquipaParticipaProva where PosicaoFinal = 1)
HAVING Nm.Nome ='AsdoVolante' AND P.Data BETWEEN '2017-01-01' AND '2017-06-30';
Tables created in SQL Server for the code:
CREATE TABLE Carro(
IdCarro INT NOT NULL,
Marca VARCHAR(20) NOT NULL,
Modelo VARCHAR(50),
PRIMARY KEY (IdCarro));
CREATE TABLE Piloto(
IdPiloto INT NOT NULL,
Nome VARCHAR(20) NOT NULL,
Morada VARCHAR(50),
Telefone INT,
PRIMARY KEY (IdPiloto));
CREATE TABLE Equipa(
IdEquipa INT NOT NULL,
Nome VARCHAR(20),
Morada VARCHAR(50),
Telefone INT,
PRIMARY KEY (IdEquipa));
CREATE TABLE Patrocinador(
IdPatrocinador INT NOT NULL,
Nome VARCHAR(20)NOT NULL,
Morada VARCHAR(50),
PRIMARY KEY (IdPatrocinador));
CREATE TABLE Prova(
IdProva INT NOT NULL,
Nome VARCHAR(20) NOT NULL,
Local VARCHAR(50) NOT NULL,
Data DATE NOT NULL,
NrVoltas INT NOT NULL,
MelhorTempo TIME,
PRIMARY KEY (IdProva));
CREATE TABLE EquipaParticipaProva(
IdInscricao INT NOT NULL,
IdEquipa INT NOT NULL,
IdCarro INT NOT NULL,
IdPiloto INT NOT NULL,
IdProva INT NOT NULL,
PosicaoFinal INT,
TempoFinal TIME,
FOREIGN KEY (IdProva) REFERENCES Prova(IdProva),
FOREIGN KEY (IdCarro) REFERENCES Carro(IdCarro),
FOREIGN KEY (IdPiloto) REFERENCES Piloto(IdPiloto),
FOREIGN KEY (IdEquipa) REFERENCES Equipa(IdEquipa),
PRIMARY KEY (IdInscricao));
CREATE TABLE Voltas(
IdVolta INT NOT NULL,
IdInscricao INT NOT NULL,
PosicaoRelativa INT NOT NULL,
TempoVolta TIME,
FOREIGN KEY (IdInscricao) REFERENCES EquipaParticipaProva(IdInscricao),
PRIMARY KEY (IdVolta, IdInscricao));
CREATE TABLE PatrocinadorOficial(
IdPatrocinador INT NOT NULL,
IdProva INT NOT NULL,
Valor MONEY NOT NULL,
FOREIGN KEY (IdProva) REFERENCES Prova(IdProva),
PRIMARY KEY (IdPatrocinador, IdProva));
CREATE TABLE PatrocinadorNaoOficial(
IdPatrocinador INT NOT NULL,
IdProva INT NOT NULL,
Valor MONEY NOT NULL,
FOREIGN KEY (IdProva) REFERENCES Prova(IdProva),
PRIMARY KEY (IdPatrocinador, IdProva));
CREATE TABLE Mecanico(
IdMecanico INT NOT NULL,
Nome VARCHAR(20),
Morada VARCHAR(50),
Telefone INT,
PRIMARY KEY (IdMecanico));
CREATE TABLE Afinacao(
IdAfinacao INT NOT NULL,
IdMecanico INT NOT NULL,
IdEquipa INT NOT NULL,
TipoAfinacao VARCHAR(20) NOT NULL,
TempoDespendido TIME,
Data DATE NOT NULL,
FOREIGN KEY (IdEquipa) REFERENCES Equipa(IdEquipa),
FOREIGN KEY (IdMecanico) REFERENCES Mecanico(IdMecanico),
PRIMARY KEY (IdAfinacao));
Inserts created in SQL Server:
INSERT INTO Carro
VALUES (1, 'Nissan', 'Skyline');
INSERT INTO Carro
VALUES (2, 'Subaru', 'Impreza');
INSERT INTO Carro
VALUES (3, 'Mitsubishi', 'Evolution');
INSERT INTO Piloto
VALUES (111, 'Piloto 1', 'Castelo Branco', 111111111);
INSERT INTO Piloto
VALUES (112, 'Piloto 2', 'Castelo Branco', 111111112);
INSERT INTO Piloto
VALUES (113, 'JaGanhou', 'Lisboa', 111111113);
INSERT INTO Piloto
VALUES (114, 'AsdoVolante', 'Lisboa', 111111114);
INSERT INTO Piloto
VALUES (115, 'AsdoPedal', 'Beja', 111111115);
INSERT INTO Piloto
VALUES (116, 'Pelo Nome', 'Santarém', 111111116);
INSERT INTO Equipa
VALUES (001, 'OsAtolados', 'Castelo Branco', 272722123);
INSERT INTO Equipa
VALUES (002, 'Sparco', 'Lisboa', 212312432);
INSERT INTO Equipa
VALUES (003, 'ESTeam', 'Castelo Branco', 272343573);
INSERT INTO Prova
VALUES (010, 'RallycrossCB', 'Castelo Branco', '2017-02-02', 4, '00:04:20');
INSERT INTO Prova
VALUES (11, 'RallyLels', 'Bells', '2017-03-04', 10, '00:10:00');
INSERT INTO Prova
VALUES (12, 'Rally Portugal', 'Fafe', '2017-05-15', 2, '00:15:00');
INSERT INTO Prova
VALUES (13, 'Rally CB', 'Castelo Branco', '2017-01-01', 2, '00:15:00');
INSERT INTO Prova
VALUES (14, 'Rally Norte', 'Porto', '2017-02-02', 2, '00:30:00');
INSERT INTO EquipaParticipaProva
VALUES (441, 002, 3, 113, 010, 1, '00:04:00');
INSERT INTO EquipaParticipaProva
VALUES (442, 1, 2, 111, 11, 1, '00:10:00');
INSERT INTO EquipaParticipaProva
VALUES (443, 3, 1, 112, 10, 1,'00:05:00' );
INSERT INTO EquipaParticipaProva
VALUES (444, 3, 1, 114, 12, 1,'00:15:00' );
INSERT INTO EquipaParticipaProva
VALUES (445, 3, 1, 114, 13, 1,'00:15:00' );
INSERT INTO EquipaParticipaProva
VALUES (446, 3, 2, 114, 14, 5,'01:00:00' );
INSERT INTO Voltas
VALUES (1, 443, 1, '00:01:15');
INSERT INTO Voltas
VALUES (2, 443, 1, '00:01:15');
INSERT INTO Voltas
VALUES (3, 443, 3, '00:01:15');
INSERT INTO Voltas
VALUES (1, 444, 1, '00:07:30');
INSERT INTO Voltas
VALUES (2, 444, 1, '00:07:30');
INSERT INTO Voltas
VALUES (1, 445, 1, '00:07:30');
INSERT INTO Voltas
VALUES (2, 445, 1, '00:07:30');
INSERT INTO Voltas
VALUES (1, 446, 5, '00:30:00');
INSERT INTO Voltas
VALUES (2, 446, 5, '00:30:00');
INSERT INTO Voltas
VALUES (4, 443, 3, '00:01:15');
INSERT INTO Voltas
VALUES (1, 441, 1, '00:01:00' );
INSERT INTO Voltas
VALUES (2, 441, 1, '00:01:20');
INSERT INTO Voltas
VALUES (3, 441, 1, '00:01:00');
INSERT INTO Voltas
VALUES (4, 441, 1, '00:01:00');
INSERT INTO Voltas
VALUES (5, 441, 1, '00:01:00');
INSERT INTO Voltas
VALUES (6, 441, 1, '00:01:00');
INSERT INTO Voltas
VALUES (7, 441, 1, '00:01:00');
INSERT INTO Voltas
VALUES (8, 441, 1, '00:01:20');
INSERT INTO Voltas
VALUES (9, 441, 1 ,'00:00:30');
INSERT INTO Voltas
VALUES (10, 441, 1, '00:01:30');
INSERT INTO Voltas
VALUES (1, 441, 10, 2, '00:00:45');
INSERT INTO Voltas
VALUES (2, 441, 10, 2, '00:01:00');
INSERT INTO Voltas
VALUES (3, 441, 10, 2, '00:01:00');
INSERT INTO Voltas
VALUES (4, 441, 10, 2, '00:01:15');
INSERT INTO PATROCINADOR
VALUES(921, 'IPCB', 'Av da Talagueira');
INSERT INTO PATROCINADOR
VALUES(922, 'Bells Bar', 'Praceta Qualquer Coisa');
INSERT INTO PATROCINADOR
VALUES(923, 'MonsterEnergy', 'USA');
INSERT INTO PATROCINADOR
VALUES(924, 'Sical', 'Lisboa');
INSERT INTO PATROCINADOROFICIAL
VALUES(923, 010, 10000);
INSERT INTO PATROCINADOROFICIAL
VALUES(921, 11, 8000);
INSERT INTO PATROCINADORNAOOFICIAL
VALUES(920, 010, 5000);
INSERT INTO PATROCINADORNAOOFICIAL
VALUES(922, 11, 3000);
INSERT INTO PATROCINADORNAOOFICIAL
VALUES(924, 10, 6000);
INSERT INTO MECANICO
VALUES(333, 'Zacarias','Leiria',933628487);
INSERT INTO MECANICO
VALUES(334, 'Zé', 'Bragança', 963628487);
INSERT INTO MECANICO
VALUES(335, 'Luís', 'Lisboa', 913628487);
INSERT INTO AFINACAO
VALUES(20, 333, 001, 'Travões', '1:00:00', '2017-02-03');
INSERT INTO AFINACAO
VALUES(21, 334, 002, 'Luzes', '00:15:00', '2017-02-03');
INSERT INTO AFINACAO
VALUES(22, 335, 003, 'Travoes', '1:00:00', '2017-02-01');
try this
SELECT P.Data, Nm.Nome, epp.PosicaoFinal
FROM Prova P, Piloto Nm, EquipaParticipaProva epp
WHERE epp.PosicaoFinal **IN** (SELECT PosicaoFinal FROM EquipaParticipaProva where PosicaoFinal = 1)
HAVING Nm.Nome ='AsdoVolante' AND P.Data BETWEEN '2017-01-01' AND '2017-06-30';
It will work for you
I have created the table stu_dep_det
CREATE TABLE `stu_dept_cs` (
`s_d_id` int(10) unsigned NOT NULL auto_increment,
`stu_name` varchar(15) , `gender` varchar(15) , `address` varchar(15),`reg_no` int(10) ,
`ex_no` varchar(10) ,
`mark1` varchar(10) ,
`mark2` varchar(15) ,
`mark3` varchar(15) ,
`total` varchar(15) ,
`avg` double(2,0),
PRIMARY KEY (`s_d_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=8 ;
then Inserted the values
INSERT INTO `stu_dept_cs` (`s_d_id`, `stu_name`, `gender`, `address`, `reg_no`, `ex_no`, `mark1`, `mark2`, `mark3`, `total`, `avg`) VALUES
(1, 'alex', 'm', 'chennai', 5001, 's1', '70', '90', '95', '255', 85),
(2, 'peter', 'm', 'chennai', 5002, 's1', '80', '70', '90', '240', 80),
(6, 'parv', 'f', 'mumbai', 5003, 's1', '88', '60', '80', '228', 76),
(7, 'basu', 'm', 'kolkatta', 5004, 's1', '85', '95', '56', '236', 79);
I want to select the min(avg) using having keyword and I have used the following sql statement
SELECT * FROM stu_dept_cs s having min(avg)
Is it correct or not plz write the correct ans....
select somecolumn1,somecolumn2
from stu_dept_cs
group by somecolumn1,somecolumn2,avg
having avg = min(avg)
or
with t1
(select rownumber() over (partition by somecolumn1,somecolumn2
order by somecolumn1,somecolumn2,avg asc) as rownum
from stu_dept_cs )
select * from t1 where rownum=1
SELECT t1.* FROM stu_dept_cs t1
LEFT JOIN stu_dept_cs t2
ON t1.avg > t2.avg
WHERE t2.stu_name IS NULL;