mysql

checking to ensure all values in a field are integers in MySQL

I have a column that is currently a floating-point number and I need to check if all the values in the column are integers. What's the easiest way to do this? ...

Mysql select from 3 tables

I have 3 difrrent table structures, I will call them A,B,C. I need to do a search on all those 3 tables at the same time, let's that I need to: A.name LIKE %Google% B.company LIKE%Google% and C.company LIKE%Google% It's posibile to get a query out for the "query type" mentionated? Best Regards! Here is what i'm looking for Select...

How many SQL Updates functions are too many

I have a scenario where I have an inordinate number of updates that have to be performed on some text (mostly 64k text type fields, but potentially some mediumtext fields as well, which I think can contain 4MB?) fields (essentially, a search and replace on those fields). Here is how I know how to do it, but am unsure if this is the best...

Best practices, PHP, tracking millions of impressions per day.

What do I have to do to make 20k mysql inserts per second possible (during peak hours around 1k/sec during slower times)? I've been doing some research and I've seen the "INSERT DELAYED" suggestion, writing to a flat file, "fopen(file,'a')", and then running a chron job to dump the "needed" data into mysql, etc. I've also heard you need ...

How to create Tinyint Field in Hibernate annotation

hi all, I have problem in creating tinyint field in MySQL database using Hibernate. I used to write the Entity class like this @Entity @Table(name="tablename") public class MyEntity { private int id; @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id") public int getId() { return id; } public void setId(int id) { ...

MySQL stored procedure: variable in WHERE clause?

Can you not do the following w/ MySQL stored procedures?/ DROP PROCEDURE IF EXISTS `test`; DELIMITER // CREATE PROCEDURE TEST (team varchar(30)) BEGIN SELECT * FROM TEAMS WHERE TEAM_ID = @team; END // Where @team (or team) is the variable passed to the stored procedure? ...

How to get duration in terms of minutes by subtracting a previous time stamp from the present time in PHP?

How to get duration in terms of minutes by subtracting a previous time stamp from the present time in PHP? The format of time stamp is like 2009-12-05 10:35:28 I want to calculate how many minutes have passed. How to do it? ...

Leading space with INSERT in MySql

I am doing search results page with PHP & MySql.When you go to the state page, it should call up DISTINCTly every city in which I have a record. It won't list any city for the cities column if they have a leading whitespace. I trim the variable before INSERTing into the database. $prcity = trim($_SESSION['prcity']); Yet I still have ...

Is there a lower limit and upper limit check function in PHP or MySQL?

Is there such a function in PHP or MySQL? function check($lower,$val, $upper) { if ($val>$lower && $val<$upper) { return $val; } if ($val<=$lower) { return $lower; } if ($val>=$upper) { return $upper; } } ...

How to calcuate elapsed time in terms of minutes in MySQL

There is a time stamp column/field in a table, and the format is like 2009-12-05 10:35:28, Now I want to get the time in terms of minutes(How many minutes have elapsed) elapsed from then on, how to do it? ...

database sharing between two servers

My current set up is a single dedicated server with Java, hibernate app running on tomcat, apache http server, MYSQL. I need to get a second server to share the load, but using the same database from the first server. The backend processing(excluding db transaction) is time consuming, hence the second server for backend processing)....

Hide / show list in PHP

I have a list generated by MySQL. When I click one item of the list, it shows a new list related to the item in the same page. Edit: Here is the code how I get the list. <?php include("./conn/connect.php"); $query = "SELECT * FROM entreprise ORDER BY id"; $result = mysql_query($query) or die("result failed: ".mysql_error...

MySQL is SELECT with LIKE expensive?

The following question is regarding the speed between selecting an exact match (example: INT) vs a "LIKE" match with a varchar. Is there much difference? The main reason I'm asking this is because I'm trying to decide if it's a good idea to leave IDs out of my current project. For example Instead of: http://mysite.com/article/391239/t...

Is there a performance difference between select * from tablename and select column1, column2 from tablename?

Possible Duplicates: Select * vs Specifying Column Names Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc. Is there a performance difference between select * from tablename and select column1, column2 from tablename? When it is select * from, the database pulls out all fields/columns which are more than...

What is the best datatype for storing URLs in a MySQL database?

What is the best datatype for storing URLs in a MySQL database? The ideal would be something that doesn't take up a lot of space but can easily handle variable length URLs. ...

populating different data with select onChange in php

Hi, i need some clarification on how to populate select(s) with data from mysql. Basically what I am trying to do is: There will be a first select box with some data in it. <select> <option>1</option> <option>2</option> <option>3</option> </select> when the user selects a option in the first select, there is a second select ...

PHP equivalent of UNIX_TIMESTAMP() of MySQL?

In MySQL: select UNIX_TIMESTAMP('2009-12-08 21:01:33') ; I need to get the value from PHP. ...

using JQuery with mySQL confusion

HI, I have code like this. what I am doing is populating the first select with the MySQL data and based on the selection the first , using jQuery, I am populating the second one. Now, my question is, can I use the same combos_get.php to populate the another select based on user selection from the second select? Is yes, then please loo...

'questions' and 'answers' with multiple answers

This question is related to this post: http://stackoverflow.com/questions/1764469/sql-design-for-survey-with-answers-of-different-data-types I have a survey app where most questions have a set of answers that are 1-5. Now we have to do questions that could have a variety of different answer types -- numeric, date, string, etc. Thanks to...

PHP Script to Backup MySQL Database

Hello. I'm trying to write a PHP script to backup a MySQL database: if ( $db_resource = mysql_connect($db_server, $db_username, $db_password, $db_newlink) ) { if ( mysql_select_db( $db_name, $db_resource ) ) { $backupFile = $db_name."_".date( "Y-m-d-H-i-s" ).".gz"; $command = "mysqldump --opt -h ".$d...