Answer the question
In order to leave comments, you need to log in
Is it possible to create a mysql query with substitution of values from a file?
There is an INSERT INTO query with data that must be inserted in turn with changeable values that are taken from the table.
Maybe there is a program or script that will generate such requests?
Example.
It is necessary to generate such queries:
INSERT INTO `TABLE` (`1`, `2`, `3`)
(text....... "Get value from table 1 column", text....... " Get value from table 2 column", text....... "Get value from table 3 column")
And there is an xls table from which to take data. The data can in principle be copied into 3 text files, or into a csv file.
Answer the question
In order to leave comments, you need to log in
you need to load the contents of the file into the database? use LOAD DATA INFILE (previously saved in csv)
yes, and by the way - WorkBench is great at automating CSV upload.
No.
there is a skl request (for Joomla)
INSERT INTO `11111_content` (`id`, `asset_id`, `title`, `alias`, `title_alias`, `introtext`, `fulltext`, `state`, `sectionid`, `mask`, `catid`, `created`, `created_by`, `created_by_alias`, `modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `images`, `urls`, `attribs`, `version`, `parentid`, `ordering`, `metakey`, `metadesc`, `access`, `hits`, `metadata`, `featured`, `language`, `xreference`)
VALUES
(0, 0, 'Заголовок ХХХХХХХХ', X'724587369874596872983GDJSFE1', X'', '<h1>Заголовок ХХХХХХХХ</h1>\n<p><img style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"images/XXXXXXXXXXX.jpg\" alt=\"XXXXXXXX\" height=\"270\" /> </p>\n<p>Текст, текст, текст, ХХХХХХХХ, текст, текст, текст YYYYYYYY \n', '', 1, 0, 0, 10, '2015-10-25 11:00:38', 42, '', '2015-10-26 13:18:19', 42, 42, '2015-10-26 13:18:19', '2015-10-25 11:00:38', '0000-00-00 00:00:00', '{\"image_intro\":\"\",\"float_intro\":\"\",\"image_intro_alt\":\"\",\"image_intro_caption\":\"\",\"image_fulltext\":\"\",\"float_fulltext\":\"\",\"image_fulltext_alt\":\"\",\"image_fulltext_caption\":\"\"}', '{\"urla\":false,\"urlatext\":\"\",\"targeta\":\"\",\"urlb\":false,\"urlbtext\":\"\",\"targetb\":\"\",\"urlc\":false,\"urlctext\":\"\",\"targetc\":\"\"}', '{\"show_title\":\"\",\"link_titles\":\"\",\"show_intro\":\"\",\"show_category\":\"\",\"link_category\":\"\",\"show_parent_category\":\"\",\"link_parent_category\":\"\",\"show_author\":\"\",\"link_author\":\"\",\"show_create_date\":\"\",\"show_modify_date\":\"\",\"show_publish_date\":\"\",\"show_item_navigation\":\"\",\"show_icons\":\"\",\"show_print_icon\":\"\",\"show_email_icon\":\"\",\"show_vote\":\"\",\"show_hits\":\"\",\"show_noauth\":\"\",\"urls_position\":\"\",\"alternative_readmore\":\"\",\"article_layout\":\"\",\"show_publishing_options\":\"\",\"show_article_options\":\"\",\"show_urls_images_backend\":\"\",\"show_urls_images_frontend\":\"\"}', 10, 0, 21, 'Текст ХХХХХХХХХХХ', 'Текст ХХХХХХХХХХ', 1, 427, '{\"robots\":\"\",\"author\":\"\",\"rights\":\"\",\"xreference\":\"\"}', 0, '*', '');
textutils, awk, sed, perl will save the father of Russian democracy.
If you can't handle it yourself, give an example of the input data and which queries should be built from them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question