I am getting an error message "error code: 1046 no database selected" using MySQL
Below is the script that I wrote, Any suggestions on why I'm getting the error message?
DROP DATABASE IF EXISTS Bookstore;
Create Database Bookstore;
Use Bookstore;
Create Table Subject
(SubjectCode nvarchar(3) Not Null primary key,
Subject nvarchar(15) Null);
Create Table Book
(ISBN nvarchar(13) Not Null primary key,
Title nvarchar(50) Null,
Author nvarchar(30) Null,
Publisher nvarchar(30) Null,
Subject_Code nvarchar(3) Null References Subject (Subject_Code),
Shelf_Location nvarchar(7) Null,
Fiction bit Null);
Use Bookstore;
Insert Into Subject
Values
('ART', 'Art'),
('BSN', 'Business'),
('BSS', 'Best Seller'),
('EDC', 'Education'),
('FNT', 'Fantasy'),
('HMR', 'Humor'),
('MST', 'Myster'),
('PHL', 'Philosophy'),
('RLG', 'Religion'),
('RMN', 'Romance'),
('SCF', 'Science Fiction'),
('SLH', 'Self Help');
Use Bookstore;
Insert Into Book
Values
('0-111-11111-1', '89 Years in a Sand Trapxx', 'Beck, Fred', 'Hill and Wang', 'HMR', 'RC-1111', '0'),
('0-15-500139-6', 'Business Programming in C', 'Milsspaugh, A.C.', 'The Dryden Press', 'BSN', 'RC-1111', '0'),
('0-394-75843-9', 'Cultural Literacy', 'Hirsch, E.D. Jr.', 'Vintage', 'Bss', 'RC-1115', '0'),
('0-440-22284-2', 'Five Days in Paris', 'Steel, Daniels', 'Dell Publishing', 'RMN', 'RC-1114', '0'),
('0-446-51251-6', 'Megatrends', 'Naisbitt, John', 'Warner Books', 'PHL', 'RC-1114', '0'),
('0-446-51652-X', 'Bridges of Madison County', 'Waller, Robert James', 'Warner Books', 'BSS', 'RC-1114', '1'),
('0-446-60274-4', 'The Rules', 'Fein/Schneider', 'Warner Books', 'SLH', 'RC-1111', '0'),
('0-451-16095-9', 'The Stand', 'King, Stephen', 'Signet', 'MST', 'RC-1113', '0'),
('0-452-26011-6', 'Song of Solomon', 'Morrision, Toni', 'Plume/Penguin', 'BSS', 'Rc-1114', '1'),
('0-517-59905-8', 'How to Talk to Anyone, Anytime, Anywhere', 'King, Larry', 'Crown', 'SLH', 'RC-1113', '0'),
('0-534-26076-4', 'A Quick Guide to the Internet', 'Filus, Steve', 'Intergrated Media Group', 'BSN', 'RC-1111', '0'),
('0-553-24484-X', 'Prospering Woman', 'Ross, Ruth', 'Bantam Brooks', 'SLH', 'RC-1111', '0'),
('0-670-85332-1', 'How to be Hap-Hap-Happy Like Me', 'Markoe, Merrill', 'Viking', 'HMR', 'RC-1113', '1'),
('0-671-67158-8', 'Time Wars', 'Rifkin, Jeremy', 'Simon and Schuster', 'PHL', 'RC-1115', '0'),
('0-697-12897-0', 'Quick Basic and QBasic Using Modular Structure', 'Filus, Steve', 'B & E Tech', 'BSN', 'RC-1112', '0'),
('0-697-21361-7', 'Desktop Publishing Using PageMaker 5.0', 'Filus, Steve', 'B & E Tech', 'BSN', 'RC-1111', '0'),
('0-8007-1213-7', 'Secrets of Closing the Sale', 'Ziglar, Zig', 'Revel', 'BSN', 'RC-1112', '0'),
('0-8041-0753-X', 'The Kitchen God''s Wife', 'Tan, Amy', 'Ivy Books', 'BSS', 'RC-1113', '1'),
('0-8109-3158-3', 'Thomas Cole', 'Powell, Earl A.', 'Abrams', 'ART', 'RC-1112', '0'),
('0-8109-8052-5', 'The Art of Walt Disney', 'Finch, Christopher', 'Albradale', 'Art', 'RC-1112', '0'),
('0-8487-0504', 'Erica Wilson''s Quilts of America', 'Wilson, Erica', 'Oxmoor House', 'ART', 'RC-1112', '0'),
('0-87826-2', 'Know Your Lhaso Apso', 'Schneider, Earl', 'The Pet Library LTD', 'SLH', 'RC-1112', '0'),
('0-89997=087-7', 'Afoot and Afield in Orange County', 'Schad, Jerry', 'Wilderness Press', 'SLH', 'RC-1112', '0'),
('0-915391-40-6', 'Designing User Interfaces', 'Powell, James E.', 'Micontrend', 'BSN', 'RC-1114', '0'),
('0-917849-25-6', 'I am enough', 'Stortz, Margaret', 'Science of Mind', 'PHL', 'RC-115', '0'),
('0-934136-27-0', 'Wine Makers Guide', 'Nury/Fugelsang', 'Western Tanager', 'MST', 'RC-1112', '0'),
('0-9616878-6-X', 'Classics, US Aircraft of World War II', 'Meyer, Mark', 'Howell Press', 'ART', 'RC-1112', '0'),
('1-55615-484-4', 'Code Complete', 'Mc Connell, Steve', 'Microsoft Press', 'BSN', 'RC-1115', '0'),
('1-82423-2218-3', 'The Way', 'Chaney, Elana', 'Tyndale', 'RLG', 'RC-1111', '0');
make sure the database is created with command:
Create Database dbname
Related
Hello I have an assignment:
Consider an employee database with two relations:
employee(employee-name, street, city)
works(employee-name, company-name, salary)
where the primary keys are underlined. Write a query to find companies whose employees earn a lower salary, on average, than the average salary at “First Bank Corporation”.
Use user defined SQL functions (create function command) as appropriate to answer the above query, the function takes the company name as the input and returns the average salary of the given
company.
I created this function:
create function avg_salary (c_name varchar(30))
returns numeric(8,6)
begin
declare a_salary numeric(8,6);
select avg(salary) into a_salary
from works
where company.company_name = c_name
group by company_name;
return a_salary;
select company_name
from works
where a_salary<(select avg(salary) from works where company_name = ’ First Bank Corporation’);
end
But I get an error message:
Error 1415 (0A000) :Not allowed to return a result set from a function
I don't understand why I get this error.
Thank you for your help
You should read the mysql manual in conjunction with your tutorial to understand mysql specifics.
The error message is clear enough (every select returns a result set) so select company_name
from works is at fault.
Selects into and set = (select...) are fine.
In addition to the error the single quote around ’ First Bank Corporation’ is odd and errors when I try to compile the function.
Also the group by company_name; will be rejected in later versions of my sql because company_name is not included in the select list. see https://dev.mysql.com/doc/refman/8.0/en/group-by-handling.html - in this case it's not needed because you are avgerageing for a specified company.
Mysql also requires delimiters to be set before and after the create function where there are multiple statements in the function see https://dev.mysql.com/doc/refman/8.0/en/stored-programs-defining.html
Try this (example includes all code I used to create all objects and insert data):
DROP TABLE IF EXISTS employee;
CREATE TABLE IF NOT EXISTS employee (
`employee-name` varchar(100) NOT NULL,
`street` varchar(100) NOT NULL,
`city` varchar(100) NOT NULL,
PRIMARY KEY (`employee-name`)
);
DROP TABLE IF EXISTS works;
CREATE TABLE IF NOT EXISTS works (
`employee-name` varchar(100) NOT NULL,
`company-name` varchar(100) NOT NULL,
`salary` numeric(8,2) NOT NULL,
PRIMARY KEY (`employee-name`)
);
INSERT INTO
employee
(`employee-name`, `street`, `city`)
VALUES
('Employee 01', '1234 State ST.', 'Your City'),
('Employee 02', '1234 State ST.', 'Your City'),
('Employee 03', '1234 State ST.', 'Your City'),
('Employee 04', '1234 State ST.', 'Your City'),
('Employee 05', '1234 State ST.', 'Your City'),
('Employee 06', '1234 State ST.', 'Your City'),
('Employee 07', '1234 State ST.', 'Your City'),
('Employee 08', '1234 State ST.', 'Your City'),
('Employee 09', '1234 State ST.', 'Your City'),
('Employee 10', '1234 State ST.', 'Your City'),
('Employee 11', '1234 State ST.', 'Your City'),
('Employee 12', '1234 State ST.', 'Your City'),
('Employee 13', '1234 State ST.', 'Your City'),
('Employee 14', '1234 State ST.', 'Your City'),
('Employee 15', '1234 State ST.', 'Your City'),
('Employee 16', '1234 State ST.', 'Your City'),
('Employee 17', '1234 State ST.', 'Your City'),
('Employee 18', '1234 State ST.', 'Your City'),
('Employee 19', '1234 State ST.', 'Your City'),
('Employee 20', '1234 State ST.', 'Your City'),
('Employee 21', '1234 State ST.', 'Your City'),
('Employee 22', '1234 State ST.', 'Your City');
INSERT INTO
works
(`employee-name`, `company-name`, `salary`)
VALUES
('Employee 01', 'Company 01', 10000.00),
('Employee 02', 'Company 01', 10000.00),
('Employee 03', 'Company 01', 10000.00),
('Employee 04', 'Company 01', 10000.00),
('Employee 05', 'Company 01', 10000.00),
('Employee 06', 'Company 02', 15000.00),
('Employee 07', 'Company 02', 15000.00),
('Employee 08', 'Company 02', 15000.00),
('Employee 09', 'Company 03', 20000.00),
('Employee 10', 'Company 03', 20000.00),
('Employee 11', 'Company 03', 20000.00),
('Employee 12', 'Company 03', 20000.00),
('Employee 13', 'Company 03', 20000.00),
('Employee 14', 'Company 03', 20000.00),
('Employee 15', 'Company 03', 20000.00),
('Employee 16', 'Company 04', 60000.00),
('Employee 17', 'Company 04', 60000.00),
('Employee 18', 'Company 04', 60000.00),
('Employee 19', 'First Bank Corporation', 17000.00),
('Employee 20', 'First Bank Corporation', 17000.00),
('Employee 21', 'First Bank Corporation', 17000.00),
('Employee 22', 'First Bank Corporation', 17000.00);
DROP FUNCTION IF EXISTS avg_salary;
DELIMITER $$
CREATE FUNCTION IF NOT EXISTS avg_salary (c_name varchar(100))
RETURNS numeric(8,2)
BEGIN
DECLARE a_salary numeric(8,2);
SELECT avg(salary) INTO a_salary FROM works WHERE `company-name` = c_name GROUP BY `company-name`;
RETURN a_salary;
END$$
DELIMITER ;
SELECT
`company-name`
FROM
works
WHERE
avg_salary(`company-name`) < avg_salary('First Bank Corporation')
GROUP BY
`company-name`
It works perfectly for me, returning Company 01 and Company 02 as results.
ADDED after comment by original poster. Query now returns Avg Salary, as well as Company Name,
SELECT
`company-name` AS `Company Name`,
avg_salary(`company-name`) AS `AVG Salary`
FROM
works
WHERE
avg_salary(`company-name`) < avg_salary('First Bank Corporation')
GROUP BY
`company-name`
try something like below:
create function avg_salary (c_name varchar(30))
returns numeric(18,6)
begin
declare a_salary numeric(18,6);
set a_salary = select avg(salary) from works where company_name = c_name;
return (a_salary);
end
select company_name from works where a_salary<(select avg_salary('First Bank Corporation'));
So I'am making a table with a char, varchar and date. I got an error message saying "Conversion failed when converting date and / or time". If anyone can help me fix, this you got sincere thank you. :D
this is my code for creating and inserting data on my table:
Create table Employee
(EMP_NUM char(3),
EMP_LNAME varchar(15),
EMP_FNAME varchar(15),
EMP_INITIAL char(1),
EMP_HIREDATE date,
JOB_CODE char (3),
EMP_YEARS char(2))
Insert into Employee (EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL,
EMP_HIREDATE, JOB_CODE)
Values (101, 'News', 'John', 'G','08-Nov-00', 502),
(102, 'Senior', 'David', 'H','12-Jul-89', 501),
(103, 'Arbough', 'June', 'E','01-Dec-96', 500),
(104, 'Ramoras', 'Anne', 'K','15-Nov-87', 501),
(105, 'Johnson', 'Alice', 'k','01-Feb-93', 502),
(106, 'Smithfield', 'William', null, '22-Jun-04', 500),
(107, 'Alonzo', 'Maria', 'D','10-Oct-93', 500),
(108, 'Washington', 'Ralph', 'B', '22-Aug-91',501),
(109, 'Smith', 'Larry', 'W', '18-Jul-97', 501),
(110, 'Olenko', 'Gerald', 'A', '11-Dec-95', 505),
(111, 'Wabash', 'Geoff', 'B', '04-Apr-91', 506),
(112, 'Smithson', 'Darlene', 'M', '23-Oct-94', 507),
(113, 'Joenbrood', 'Delbert', 'K', '15-ov-96', 508),
(114, 'Jones', 'Annelise', null, '20-Aug-93', 508),
(115, 'Bawangi', 'Travis', 'B','25-Jan-92', 501),
(116, 'Pratt', 'Gerald', 'L','05-Mar-97', 510),
(117, 'Williamson', 'Angie', 'M', '19-Jun-96', 509),
(118, 'Frommer', 'james', 'J','04-Jan-05', 510);
and this is the complete message result :
Msg 241, Level 16, State 1, Line 11
Conversion failed when converting date and/or time from character string.
Use CONVERSION for EMP_HIREDATE column for date :
For ex :
SELECT CAST('18-Jul-97' AS DATE)
In your query :
Insert into Employee (EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL,
EMP_HIREDATE, JOB_CODE)
SELECT 101, 'News', 'John', 'G',CAST('08-Nov-00' AS DATE), 502
I exported the database of a Wordpress. So far so good. But when i tried to import it through PHPMyAdmin from a cPanel i started receiving the following error:
INSERT INTO wp_commentmeta VALUES (
"1", "1", "_wp_trash_meta_status", "1" );
MySQL said: Documentation
1030 - Got error -1 from storage engine
I tried changing the browser, the host, exporting the database through different modules. Nothing worked.
I also tried fixing the database using the 'repair' function available in the cPanel but it didn't worked as i got this in response:
[projamz1_pds.wp_commentmeta] note: The storage engine for the table
doesn't support repair [projamz1_pds.wp_comments] note: The storage
engine for the table doesn't support repair
[projamz1_pds.wp_layerslider] note: The storage engine for the table
doesn't support repair [projamz1_pds.wp_links] note: The storage
engine for the table doesn't support repair [projamz1_pds.wp_options]
note: The storage engine for the table doesn't support repair
[projamz1_pds.wp_popover_ip_cache] note: The storage engine for the
table doesn't support repair [projamz1_pds.wp_postmeta] note: The
storage engine for the table doesn't support repair
[projamz1_pds.wp_posts] note: The storage engine for the table doesn't
support repair [projamz1_pds.wp_revslider_css] note: The storage
engine for the table doesn't support repair
[projamz1_pds.wp_revslider_layer_animations] note: The storage engine
for the table doesn't support repair
[projamz1_pds.wp_revslider_settings] note: The storage engine for the
table doesn't support repair [projamz1_pds.wp_revslider_sliders] note:
The storage engine for the table doesn't support repair
[projamz1_pds.wp_revslider_slides] note: The storage engine for the
table doesn't support repair [projamz1_pds.wp_revslider_static_slides]
note: The storage engine for the table doesn't support repair
[projamz1_pds.wp_term_relationships] note: The storage engine for the
table doesn't support repair [projamz1_pds.wp_term_taxonomy] note: The
storage engine for the table doesn't support repair
[projamz1_pds.wp_terms] note: The storage engine for the table doesn't
support repair [projamz1_pds.wp_usermeta] note: The storage engine for
the table doesn't support repair [projamz1_pds.wp_users] note: The
storage engine for the table doesn't support repair
The code that i suppose is the core of the problem is:
INSERT INTO wp_commentmeta (meta_id, comment_id, meta_key,
meta_value) VALUES (1, 1, '_wp_trash_meta_status', '1'), (2, 1,
'_wp_trash_meta_time', '1425058099'), (3, 18, '_wp_trash_meta_status',
'0'), (4, 18, '_wp_trash_meta_time', '1425058099'), (5, 34,
'_wp_trash_meta_status', '0'), (6, 34, '_wp_trash_meta_time',
'1425058099'), (7, 33, '_wp_trash_meta_status', '0'), (8, 33,
'_wp_trash_meta_time', '1425058099'), (9, 10, '_wp_trash_meta_status',
'0'), (10, 10, '_wp_trash_meta_time', '1425058099'), (11, 9,
'_wp_trash_meta_status', '0'), (12, 9, '_wp_trash_meta_time',
'1425058099'), (13, 19, '_wp_trash_meta_status', '1'), (14, 19,
'_wp_trash_meta_time', '1425058099'), (15, 23,
'_wp_trash_meta_status', '1'), (16, 23, '_wp_trash_meta_time',
'1425058099'), (17, 22, '_wp_trash_meta_status', '1'), (18, 22,
'_wp_trash_meta_time', '1425058099'), (19, 32,
'_wp_trash_meta_status', '0'), (20, 32, '_wp_trash_meta_time',
'1425058099'), (21, 31, '_wp_trash_meta_status', '0'), (22, 31,
'_wp_trash_meta_time', '1425058099'), (23, 3, '_wp_trash_meta_status',
'0'), (24, 3, '_wp_trash_meta_time', '1425058099'), (25, 30,
'_wp_trash_meta_status', '0'), (26, 30, '_wp_trash_meta_time',
'1425058099'), (27, 29, '_wp_trash_meta_status', '0'), (28, 29,
'_wp_trash_meta_time', '1425058099'), (29, 28,
'_wp_trash_meta_status', '0'), (30, 28, '_wp_trash_meta_time',
'1425058099'), (31, 15, '_wp_trash_meta_status', '0'), (32, 15,
'_wp_trash_meta_time', '1425058099'), (33, 27,
'_wp_trash_meta_status', '0'), (34, 27, '_wp_trash_meta_time',
'1425058099'), (35, 26, '_wp_trash_meta_status', '0'), (36, 26,
'_wp_trash_meta_time', '1425058099'), (37, 2, '_wp_trash_meta_status',
'0'), (38, 2, '_wp_trash_meta_time', '1425058099'), (39, 25,
'_wp_trash_meta_status', '0'), (40, 25, '_wp_trash_meta_time',
'1425058099'), (41, 24, '_wp_trash_meta_status', '0'), (42, 24,
'_wp_trash_meta_time', '1425058104'), (43, 8, '_wp_trash_meta_status',
'1'), (44, 8, '_wp_trash_meta_time', '1425058104'), (45, 7,
'_wp_trash_meta_status', '1'), (46, 7, '_wp_trash_meta_time',
'1425058104'), (47, 6, '_wp_trash_meta_status', '1'), (48, 6,
'_wp_trash_meta_time', '1425058104'), (49, 5, '_wp_trash_meta_status',
'1'), (50, 5, '_wp_trash_meta_time', '1425058104'), (51, 4,
'_wp_trash_meta_status', '1'), (52, 4, '_wp_trash_meta_time',
'1425058104'), (53, 11, '_wp_trash_meta_status', '1'), (54, 11,
'_wp_trash_meta_time', '1425058104'), (55, 14,
'_wp_trash_meta_status', '1'), (56, 14, '_wp_trash_meta_time',
'1425058104'), (57, 13, '_wp_trash_meta_status', '1'), (58, 13,
'_wp_trash_meta_time', '1425058104'), (59, 12,
'_wp_trash_meta_status', '1'), (60, 12, '_wp_trash_meta_time',
'1425058104'), (61, 17, '_wp_trash_meta_status', '1'), (62, 17,
'_wp_trash_meta_time', '1425058104'), (63, 16,
'_wp_trash_meta_status', '1'), (64, 16, '_wp_trash_meta_time',
'1425058104');
Tho' i did not wanted to delete it and import like that because i am afraid i will break something.
Any suggestions?
LE: I tried importing without the part i suspected being the problem. Without success. Still the same error - #1030 - Got error -1 from storage engine . But now i got 2 tables imported instead of one. Still cannot figure out the problem. As the wordpress is working without any kind of problem. I think something happens when i try to export the database.
Cheers
Some cheap and nasty shared hosting providers don't support all the MySQL access methods.
Try this: For each table find the part of the SQL file generated by your export that looks like this, for example.
CREATE TABLE `wp_options` (
`option_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`option_name` VARCHAR(64) NOT NULL DEFAULT '',
`option_value` LONGTEXT NOT NULL,
`autoload` VARCHAR(20) NOT NULL DEFAULT 'yes',
PRIMARY KEY (`option_id`),
UNIQUE INDEX `option_name` (`option_name`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
;
Delete the line saying ENGINE=something, and retry your import. That will allow the MySQL server to use whatever ENGINE it has available.
I am having an issue with the code below and my issue is the following:
I need to be able to select the shop_shipping_rule_region_code if the country_iso is NULL but I also need to get the $country_iso data as well if present
What I am after:
The Final Result will have:
Overnight UPS
NZ Snail Mail
Whole World (in this example)
DB:
`shop_shipping_rules` (`shop_shipping_rule_id`, `shop_shipping_rule_country_iso`, `shop_shipping_rule_region_code`, `shop_shipping_rule_name`,
`shop_shipping_rule_type_single`, `shop_shipping_rule_item_single`, `shop_shipping_rule_type_multi`,
`shop_shipping_rule_item_multiple`,`shop_shipping_rule_created`, `shop_shipping_rule_modified`, `website_id`)
VALUES
(41, 'NZ', 'ALL', 'Overnight UPS', 'single', 2.00, 'multi', 4.00, '2013-11-05 02:30:19', '2013-11-05 03:00:27', 64),
(44, 'NZ', NULL, 'NZ Snail Mail', 'single', 25.00, 'multi', 35.00, '2013-11-14 03:57:06', NULL, 64),
(45, NULL, 'ALL', 'Whole World', 'single', 90.00, 'multi', 150.00, '2013-11-14 05:05:53', NULL, 64),
(46, NULL, 'EU', 'EU Ship', 'single', 28.00, 'multi', 35.00, '2013-11-15 01:04:01', NULL, 64);
if (isset($country_iso))
$sql = "SELECT * FROM shop_shipping_rules WHERE country_iso IS NULL OR country_iso = '$country_iso' ";
else
$sql = "SELECT * FROM shop_shipping_rules WHERE country_iso IS NULL";
I'm trying to pass data from my table OpenCart version 1.5.1.3 to version 1.5.3.1. I'll be using a new theme and only a few of the modules used in the previous version, but do not want to lose the data records of customers, sales and products.
Bearing this in mind I guess the easiest way would be estrair the table to a SQL script (I used phpmyadmin), but there are some differences between the versions for the database schema and data so I am not able to pass data from a table another.
As an example I'll use the table "address" 1.5.1.3 version that has the following structure when exported by phpmyadmin:
INSERT INTO `address` (`address_id`, `customer_id`, `firstname`, `lastname`, `company`, `address_1`, `address_2`, `city`, `postcode`, `country_id`, `zone_id`) VALUES
(6, 6, 'Fulano', 'Silva', '', 'My Street, 455', 'Neighborhood 1', 'City 1', 'd9c 5t7', 30, 464),
(2, 2, 'Cicrano', 'Souza', '', 'My Avenue, 921', 'Neighborhood 2', 'City 2', 'd9c 5t7', 30, 464),
(4, 4, 'Beltrano', 'Cabrito', '', 'My Street 2, 191', 'Neighborhood 3', 'City 3', 'd9c 3t7', 30, 464);
And the database version 1.5.3.1 follows this model:
INSERT INTO `address` (`address_id`, `customer_id`, `firstname`, `lastname`, `apelido`, `company`, `company_id`, `tax_id`, `address_1`, `numero`, `address_2`, `complemento`, `city`, `postcode`, `country_id`, `zone_id`) VALUES
(6, 6, 'Fulano', 'Silva', '', '', '', '', 'My Street', '455', 'Neighborhood 1', '', 'City 1', 'd9c 5t7', 30, 464),
(2, 2, 'Beltrano', 'Cabrito', '', '', '', '', '', 'My Street 2', '191', 'Neighborhood 3', '', 'City 3', 'd9c 3t7', 30, 464);
This is repeated in several tables, now how do I get only the data you want from v1.5.1.3 to v1.5.3.1 using SQL or other simpler if any?
This is why the upgrade script is there. You can find out how to upgrade here