mysql

MySQL substring performance

Hi, Does anybody know what the performance of using substring in MySQL is like? I have some insert and update calls where I have to truncate all the fields (up to around 15) using substring statements. These will get call pretty regularly so I'm a little worried about performance. ...

How to enable Server choosing on PhpMyAdmin?

Hi, I'm running XAMPP on my local host, and i want phpmyadmin to add another field of server on login page, so i can manage an external mysql server as well.. Is that possible? Thanks ...

INSERT fails on server with magic_quotes on

Ive been struggling to get my data to insert into my table. The data is pulled from an xml file into an array and echo'ing the results are fine but it fails on insertion. $dbhost = 'XXXX'; $dbuser = 'XXXX'; $dbpass = 'XXXX'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); if($conn) { echo "D...

What do column flags mean in MySQL Workbench?

In MySQL Workbench table editor there are 7 column flags available: PK, NN, UQ, BIN, UN, ZF, AI. PK obviously stands for Primary Key. What about others? ...

Search using LIKE Clause Mysql

I'm tring to convert a Mysql query to using a LIKE clause and I can't make it work. $query = "SELECT id,name FROM `hin` WHERE name = '".$q."'"; What I've tried in some variations. $query = "SELECT id,name FROM `hin` WHERE name LIKE %'".$q."'%"; I need the query to select row only on string match. Intend is to use variable as needle...

Using DAY(), WEEK(), and YEAR() at one query

i using MySQL Query for my task. And I interested using Date and time function. can i use DAY(), WEEK(), and YEAR() at one query? SELECT Object FROM table WHERE DAY(date) BETWEEN 1 AND 7 GROUP BY WEEK(date, 1), YEAR(date) i want do this bcoz i'm worry if sometimes my program have an error because of the date setting and not rec...

Ultra simple ASP SQL on GoDaddy free hosting.

I know it can be simple to access a mysql or sql database on godaddy.. i have done it before, but now i have lost the code. Now the code that should be working just comes up with a security exception. So how do i create a asp or aspx file on my godaddy free hosting account that will connect to a database i have already set up (mysql,sql...

PHP MySQL getting top five highest results. ?

have a poll table which has 10 categories and I want to view the top 5 results from highest to lowest limit into 5 categories. How can I do this in php and mysql? here are example tables categories id category_name Votes id category_id user_id Users id username here is my sample query: $q = mysql_query("SELECT * from categ...

How to group mysql rows with same column value into one row?

I have to tables, keywords and data. Table keywords have 2 columns (id, keyword), table data have 3 columns (id[foreign key of keywords.id], name, value). I am using this query: SELECT k.id, d.value, d.name FROM keywords AS k INNER JOIN data as d ON k.id = d.id it returns something like: 1 123 name1 1 456 name2 2 943 name1 3 542 n...

How select these specific rows in MySQL?

In MySQL table, I have a field called "Tag", which may include multiple comma-delimited values. I want to select rows where the Tag field contain the value of "1". How would I write my MySQL statement so I select rows with Tag values of "1" and "1,Cars", but exclude the rows with Tag values of "17" and "17,Cars"? The problem that I'm...

It is possible to fetch with a single SQL the minimum (maximum) row in the table when the compared value is combined of two separate fields?

Dear ladies and sirs. Examine the following scenario. There is a table with two columns - DateWithoutMilliseconds and Milliseconds. Together these two columns define the exact timestamp with the milliseconds. Is it possible to write a single SQL statement (not using stored procedures) which would fetch the row with the minimum timestam...

How to convert PHP array into Mysql resource

I have the following scenario. I must run a query and then save it to memory, and if I need the same result again to obtain it from memory. Storing and reading from memory is made with memcache. The problem is that if you hold information in an array one at a time just have to treat two cases: 1 for resource type and one for array type....

Function won't accept less than three arguments

Hello Stack Overflow! I'm working with someone else's database connection PHP function that works fine as long as I pass it at least three arguments. If I pass it two argument, then the apache log says: mysql_real_escape_string() expects parameter 2 to be resource, null given I need the function to take a SQL query like so: $sql = D...

Help Optimizing a Query

Hi all, I need to optimize a query in MySQL i am retrieving a set a records from the database and populating in a grid view...but it takes around 45 sec for the grid view to be populated...This is my query: SELECT Distinct vc.VideoCategoryId, video.Id as VideoId, video.VideoTitle as Title, video.ArticleAbstract as Des...

Mysql time stamp queries

I have a column that uses time stamp. My question is I am a bit confused about how to make queries against it,how would I say Where $time is after X date Are queries made in local time or CUT? When I just try to do where andthe post date /time I get an error because of the space and if I quote it I think it takes it as a string : / ...

What's the fastest way to poll a MySQL table for new rows?

My application needs to poll a MySQL database for new rows. Every time new rows are added, they should be retrieved. I was thinking of creating a trigger to place references to new rows on a separate table. The original table has over 300,000 rows. The application is built in PHP. Some good answers, i think the question deserves a boun...

selecting invalid dates

In the following example, I am getting all the values greater than '2009-11-29' as well as NULL and '0000-00-00'. Is there any other way to get the same results? mysql>select * from totest; +---------------------+ | stime | +---------------------+ | 0000-00-00 00:00:00 | | 2009-12-12 12:22:32 | | 0000-00-00 00:00:00 | |...

Count of total groups required. Group by cluased query in MySql

Hi; I want the count of a total groups. I have following query. I want how many groups this query returned based on web_id. Lets suppose if it grouped under 4 groups. I need count 4. select * from web_details where redirected = false group by web_id I hope my question is understood. ...

How to get unique result in mysql.

I have table: name marks aaa 100 aaa 56 aaa 120 bbb 56 bbb 60 The result should be: aaa 120 bbb 60 ie unique name with maximum marks. Is there any query in mysql? ...

Querying multiple mySQL tables simultaneously

Hi guys, as the title states, I am trying to query multiple mySQL tables in the same DB simultaneously, here is my query, SELECT * FROM `database_db`.`one, two, three, four, five, six, seven` WHERE uid='1234567' I am using mySQL workbench to do the query, but when I run it I get this error Error Code: 1103 Incorrect table name 'one,...