Re: Help with query MySQL and PHP
This question is strictly related to the mysql query not the php code. I need to either create a new table from the old one or add columns. The thing is don't know how to do it. let me simplify things up: I need a query to retrieve values from the table PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS to a new one or add columns. the new table should look like ID Hair Eyes Blond Green Brunette Hazel The php code is not what I want I need the query, to do exactly that. Then I will use it in my php code, but what that is not what I am asking at this time. Just the query to do that. Thanks, Rick Fitzgerald John Meyer wrote: It would be better to post this sort of question at [EMAIL PROTECTED] axis wrote: Hi, I want to create a new column or table from queries of the values of columns I( already have. My table is : PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS products_id products_extra_fields_id products_extra_fields_value 1 1 Blond 1 2 Green 1 3 1.75 1 4 24 2 1 Brunette 2 2 Hazel 2 3 1.56 2 4 28 with this Select query function get_extra($extra_array = '') { if (!is_array($extra_array)) $extra_array = array(); $extra_query = db_query(select products_extra_fields_value from . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . where products_extra_fields_id = '1'); while ($extra = db_fetch_array($extra_query)) { $extra_array[] = array('id' = $extra['products_extra_fields_id'], 'text' = $extra['products_extra_fields_value']); } return $extra_array; } This function uses the query: select products_extra_fields_value from PRODUCTS_EXTRA_FIELDS where products_extra_fields_id = 1; and returns Rubia and Morocha which is fine, now I need to either create a new column or table in order to be able to have those values in their own column my knowledge of mysql is limited so please give me suggestions as what to use in order to create a function to retrieve values and add them automatically to my table or columns The table or columns have to be something like: ID Hair Eyes Blond Green Brunette Hazel so I can call them later by selecting from a column in a table like TABLE_PRODUCTS_EXTRA_FIELDS_TO_PRODUCTS_EXTRA_FIELDS_VALUE pef2pev.hair, pef2pev.eyes ... and so on here is my current switch for ($i=0, $n=sizeof($column_list); $i$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; // aDD eXTRA FIELdS case 'PRODUCT_LIST_HAIR': $select_column_list .= 'pef2pev.hair, '; break; and so on ... break; } } Thanks Rick Fitzgerald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Help with query MySQL and PHP
Hi, I want to create a new column or table from queries of the values of columns I( already have. My table is : PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS products_id products_extra_fields_id products_extra_fields_value 1 1 Blond 1 2 Green 1 3 1.75 1 4 24 2 1 Brunette 2 2 Hazel 2 3 1.56 2 4 28 with this Select query function get_extra($extra_array = '') { if (!is_array($extra_array)) $extra_array = array(); $extra_query = db_query(select products_extra_fields_value from . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . where products_extra_fields_id = '1'); while ($extra = db_fetch_array($extra_query)) { $extra_array[] = array('id' = $extra['products_extra_fields_id'], 'text' = $extra['products_extra_fields_value']); } return $extra_array; } This function uses the query: select products_extra_fields_value from PRODUCTS_EXTRA_FIELDS where products_extra_fields_id = 1; and returns Rubia and Morocha which is fine, now I need to either create a new column or table in order to be able to have those values in their own column my knowledge of mysql is limited so please give me suggestions as what to use in order to create a function to retrieve values and add them automatically to my table or columns The table or columns have to be something like: ID Hair Eyes Blond Green Brunette Hazel so I can call them later by selecting from a column in a table like TABLE_PRODUCTS_EXTRA_FIELDS_TO_PRODUCTS_EXTRA_FIELDS_VALUE pef2pev.hair, pef2pev.eyes ... and so on here is my current switch for ($i=0, $n=sizeof($column_list); $i$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; // aDD eXTRA FIELdS case 'PRODUCT_LIST_HAIR': $select_column_list .= 'pef2pev.hair, '; break; and so on ... break; } } Thanks Rick Fitzgerald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
What's the best way to INSERT a long list of email addresses and names into a TABLE?
Hi, I have a long list of email addresses, and names in a text file in csv format, and I want to know what's the best approach to quickly INSERT them into my customers TABLE. Initially I thought it could be easy to just add SQL INSERTs to the database dump but, the problem is I have to manually add some fields and that can be a tedious and slow process, is there a better approach? This is the table structure: CREATE TABLE `customers` ( `customers_id` int(11) NOT NULL auto_increment, `purchased_without_account` tinyint(1) unsigned NOT NULL default '0', `customers_gender` char(1) NOT NULL default '', `customers_firstname` varchar(32) NOT NULL default '', `customers_lastname` varchar(32) NOT NULL default '', `customers_dob` datetime NOT NULL default '-00-00 00:00:00', `customers_email_address` varchar(96) NOT NULL default '', `customers_default_address_id` int(11) default NULL, `customers_telephone` varchar(32) NOT NULL default '', `customers_fax` varchar(32) default NULL, `customers_password` varchar(40) NOT NULL default '', `customers_newsletter` char(1) default NULL, `customers_group_name` varchar(27) NOT NULL default 'Retail', `customers_group_id` int(11) NOT NULL default '0', PRIMARY KEY (`customers_id`), KEY `purchased_without_account` (`purchased_without_account`) ) TYPE=MyISAM AUTO_INCREMENT=60 ; I only have Name and Email in the text file. Sincerely, Axis -- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
What's the best way to INSERT a long list of email addresses and names into a TABLE?
I have a long list of email addresses, and names in a text file in csv format, and I want to know what's the best approach to quickly INSERT them into my customers TABLE. Initially I thought it could be easy to just add SQL INSERTs to the database dump but, the problem is I have to manually add some fields and that can be a tedious and slow process, is there a better approach? This is the table structure: CREATE TABLE `customers` ( `customers_id` int(11) NOT NULL auto_increment, `purchased_without_account` tinyint(1) unsigned NOT NULL default '0', `customers_gender` char(1) NOT NULL default '', `customers_firstname` varchar(32) NOT NULL default '', `customers_lastname` varchar(32) NOT NULL default '', `customers_dob` datetime NOT NULL default '-00-00 00:00:00', `customers_email_address` varchar(96) NOT NULL default '', `customers_default_address_id` int(11) default NULL, `customers_telephone` varchar(32) NOT NULL default '', `customers_fax` varchar(32) default NULL, `customers_password` varchar(40) NOT NULL default '', `customers_newsletter` char(1) default NULL, `customers_group_name` varchar(27) NOT NULL default 'Retail', `customers_group_id` int(11) NOT NULL default '0', PRIMARY KEY (`customers_id`), KEY `purchased_without_account` (`purchased_without_account`) ) TYPE=MyISAM AUTO_INCREMENT=60 ; I only have Name and Email in the text file. Sincerely, Axis -- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Best way to copy between two databases with the same tables but different number of rows
Hi, I'm trying to copy between two databases with the same tables, but the destination one has a different number of rows. I used SQLyog first to create the script with the necessary commands and it partially worked after applying it to the second table, but my problem is with one of the tables with the same name, in both databases and with a different number of rows. when I issue INSERTs from the source database, to add the records in the destination, it complains the number of rows is different, that's strange so I am looking a way to fix this, and this is the first time I am doing it so please advise me. Thank you, Rick Fitzgerald -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Pls Help !
I'm trying to figure out how can I do this: I'm designing a mysql db for a delivery service, and I encounter a problem each item delivered has a code associated and it also does some querys in other associated tables, I mean: Prod ID = 11 Prod = PizzaRecipeID=01 REcipe has the ingredients and each time a prod is ordered all the ingredients are added to a day total. I mean the employee enters the code for Pizza, then it adds the pizza individual ingredients to the day total, there are also combined orders, my problem is which is the best way to create an associated table with each of the item ingredients (they have to be editable), because they have unique recipes that are modifiable. I mean Products Recipes - ProdIdName ... (other fields) RecIDDesc 01Pizza 11 Pizza and here is my problem RecipesDesc RecId Item qtyestcost 11 Flour 11 Tomato each item must be edited so RecId will be repeated for many times, so by the end of the day if I want to know how much flour was spent I will have the same ingredient repeated all over in different recipes, which is the best way to overcome this ? I couldn't figure it out, Thank you, Ricardo Fitzgerald Web Developer __ Omni ICQ#: 37031810 Current ICQ status: + More ways to contact me __ - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: [PHP] Questions regarding inserting and updating data into a MySQL db
Thanks for the tip I will try that, I'm still learning MySQL and PHP, although I did a couple of complex applications, there are some techniques that still are 'obscure' to me. Regards, Ricardo Fitzgerald AXIS Computers - Original Message - From: Chris Shiflett [EMAIL PROTECTED] To: Axis Computers [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; PHP [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 7:24 PM Subject: Re: [PHP] Questions regarding inserting and updating data into a MySQL db You should search for some SQL tutorials on the Web. What it sounds like you are looking for is the update SQL statement which modifies an existing row (for your second form, for example). Thus, you insert the row to create it (which assigns the key using the auto increment), then update that row to make any modifications you need to after that. Happy hacking. Chris Axis Computers wrote: I'm developing a web application that uses forms for user input and then after each form is filled shows something like Welcome Bob to our site ... bla. bla... inserts data in a table and on the same page continues with the rest of the data, and goes to another form and so on. I have no problems inserting the data from the first form in the table, display the personalized message, and then connect to the mySQL db, my problem is some fields in the table which must be filled are null in this first instance, and then on the second form they are filled, but my I donĀ“t know how can I fill the gaps and leave all the data in one row, because the first field auto increments, and I'm worried the data instead of filling one row spreads accross two or three. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php