mysql-query

Changes reflected in dataset, but NOT db

I'm trying to migrate from an Access db to a MySql and don't have much experience with the latter. I wrote some sample code to write data that works one way, but not another and I'm not seeing the difference. Basically, the way that WORKS connects to the MySql database, extracts a dataset, creates a new row of data, adds it to the datas...

How to get hour from subtract date and time in mysql?

How to get hour from subtract date and time in mysql? 2010-12-04 17:07:14 and 2010-05-30 17:07:19 ...

inner join, passing data from table for edit

so i have now a working inner join table. my problem is i dont know how to pass the correct values for editing in the select area. after i update. its error is Cannot add or update a child row: a foreign key constraint fails (`sadsystem/products`, CONSTRAINT `products_ibfk_3` FOREIGN KEY (`size_id`) REFERENCES `product_sizes` (`size_id`...

foreign key constraint

I'm having trouble editing the data in mysql with foreigh keys. When I try to update a foreign key, it says: Cannot add or update a child row: a foreign key constraint fails (sadsystem/products, CONSTRAINT fk_ProductRelationship11 FOREIGN KEY (size_id) REFERENCES product_sizes (size_id)) ...

how to get data from three tables by a join statement in mysql

Hi Guys, In my application i have three tables, reservation, patient and sub_unit, i need to take the patient_id from reservation table and query the patient table for patient data,same time i need to take the sub_unit_id from the reservation table and query the sub_unit name from the sub_unit table... i need to put all this data in to ...

MySQL, need some performance suggestions on my match query

I need some performance improvement guidance, my query takes several seconds to run and this is causing problems on the server. This query runs on the most common page on my site. I think a radical rethink may be required. ~ EDIT ~ This query produces a list of records whose keywords match those of the program (record) being queried. My...

foreign key editing

why is it the first time i edit a forein key it allows me to edit its value and then after the second try it brings up an error like this Cannot add or update a child row: a foreign key constraint fails (`sadsystem/products`, CONSTRAINT `products_ibfk_3` FOREIGN KEY (`size_id`) REFERENCES `product_sizes` (`size_id`) ON DELETE CASCADE ON...

edit query error with foreign key constraints

ok here it is. i have a table product with foreign keys from product_sizes,brands,categories, and suppliers table. when i display the products table to a html. i use JOIN so that the data displayed in the products table is not the id's of the foreign keys but rather its corresponding names.. i have no problem with the query in regards of...

Slow MySQL full text search

Hi guys, I'm using this query to perform a full text search on a MySQL database: SELECT DISTINCT questions.id, questions.uniquecode, questions.spam, questions.questiondate, questions.userid, questions.description, users.login AS username, questions.questiontext, questions.totalvotes, MATCH(questions.questiontext, questions.uniquecode...

Connected Subgraphs in MySQL using adjacency list?

I remember doing this long back in MySQL using depth-first search but can't remember how I did it. Is there a way to do this directly using a query? I am able to do this in a scripting language but am curious to see the performance using MySQL. Basically, the problem is that I have an adjacency list stored in a table: A | B ----- 1 | 2 ...

Single query or multiple queries

I have a table having 4 columns and I need to insert over 5k rows. Is it good to insert them using 1 query, or each row having its separate query. The database is mysql. ...

How MySQL manage multiple queries from multiple users simultaneously?

Just to give you an example: I have a PHP script that manages users votes. When a user votes, the script makes a query to check if someone has already voted for the same ID/product. If nobody has voted, then it makes another query and insert the ID into a general ID votes table and another one to insert the data into a per user ID vote...

MySQL I want to optimize this further...

So I started off with this query: SELECT * FROM TABLE1 WHERE hash IN (SELECT id FROM temptable); It took forever, so I ran an explain: mysql> explain SELECT * FROM TABLE1 WHERE hash IN (SELECT id FROM temptable); +----+--------------------+-----------------+------+---------------+------+---------+------+------------+-------------+ | ...

Most efficient way - PHP/MYSQL requests - Real time news system

Hi there, I've got a quick performance question for my real time news system. This is a community news system, where everybody can post his news, and vote for it, or vote for other news. Every 20secs in jQuery I search in the DB to refresh the 20 last news/votes. But at the moment, I extract every 20sec the last 20 questions, even if ...

sql and mysql combined query

Hi , i have tableA in sql database , and tableB in mysql database , How to write the join and which function should i use for that(myssql_query or mssql_query ) Thanks ...

Drupal Slow Query Log Analysis

Hi, I turned the slow queries on for a Drupal site and following are the top 10 slow queries. Any idea on how I can find their source or origin Reading mysql slow query log from /var/log/mysql/mysql-slow.log Count: 1 Time=220.72s (220s) Lock=0.00s (0s) Rows=14293563.0 (14293563), root[root]@localhost SELECT /*!N SQL_NO_CACHE */ *...

cross table from two table in MySql

I have two tables, one parts_raised and another is parts_detail. parts_raised: SN(int),Job_Number(int),Category(varchar),Part_code(int),technician(varchar),Time (timestamp), Parts_detail: Part_code(int),Value(int),Descriptions(text), part_code is same in both table. How can i write query for achieving total count of jobs,and ...

PostgreSql + Searching Issue for "'" present in string

Here, I have a problem in searching record in Postgresql DB in RoR Application. Name of table :: address_books, name of attributes :: organization_name, federal_tax_id, city, zip , business_name. In search, organization name contain :: Claire's Inc as record. At the time of searching, it does not show the data while we select Claire's I...

How to do this query

Hi ALL THere is a data table from a flower shop which looks like CustomerID Flower John peony John lily John Lotus Mary peony Mary lily Mary chrysanthemum Lisa chrysanthemum Lisa ...

PHP MySQL, Query error

$sql = "UPDATE `$db_name`.`$tbl_name` SET `u_code` = '$u_code' WHERE `$tbl_name`.`email` = `$mail`;"; $result=mysql_query($sql); Whenever an email id (eg: [email protected]) is entered and the query is run then error occurs (No such e-mail exists in the database , Although it is present) but after some experiments it is found t...