mysql

Are ids in mysql guaranteed not to be repeated, even if rows are deleted?

Of course if I put enough rows eventually there will be a repeat. But let's assume I choose a big enough id field. I want to know if I can assume that the id uniquely identifies the row over time. And if the client sends me an id I want to be able to determine what row it refers or if the row was deleted (or if it is a fake id, but in t...

Check user rights before attempting to CREATE DATABASE

Some hosters let your script CREATE DATABASE, some do not, and require you to use their control panels instead. How do I check whether database would let me run this query with given user/password without actually creating any databases? Because if I don’t have enough rights, I just want to hide the “Create database” button from UI alto...

Mysql full text indexing limitations?

What are the limitations or gotchas or antipatterns or pitfalls? It seems pretty attractive, apparently you can create a search engine with almost no work. But it cannot be without its problems... what are your experiences? ...

Propel - SQL: extract a month from a date

I'm trying to build a query with propel Criteria to get all Foo's in a given month. For example I want all Foo's in March. In regular SQL I would build a query like this: SELECT * FROM FooPeer WHERE MONTH(startDate) = 3 Any Idea how I can implement the "MySQL Month-function within a Criteria Object" ? $c = new Criteria(); $c -> add(...

How can I find people to check and play with beta version ?

I'm working with third party tools for databases software company. We've developed a great query tool for different kind of databases, and now we looking for people to play with it and tell us what they think and if everything is working ok. You have any idea where can find people who will want to do it? Added by edit : This is the...

binding results into php array

I am trying the following code to get results from query and display it in the tes.php page. db.inc.php <?php function db_connect() { $handle=new mysqli('localhost','rekandoa','rekandoa','rekandoa'); if (!$handle) { return false; } return $handle; } function get_member() { $handle=db_connect(); $sql="Select email,na...

Determining if a lat-long circle and a circle on a sphere overlap

I am creating an application with Geo Proximity Search capability using PHP as server scripting language and MySQL as Databse. Consider a situation: Where we have certain set of objects having latitude and longitude positions assosciated with respective objects. On specifying location details like country and/or city along with range/r...

Database structure for holding statistics by day, week, month, year

Hello all, I have to collect statisctics by days, weeks, months and years of user activity for a site. I am the DB design stage and I wanted to do this stage properly since it will make my coding life easier. What I have to do is just simply increment the values in the fields by 1 in the DB each time an activity happens. So then I can ...

Maximum number of workable tables in SQL Server And MySQL

I know that in SQL Server, the maximum number of "objects" in a database is a little over 2 billion. Objects contains tables, views, stored procedures, indexes, among other things . I'm not at all worried about going beyond 2 billion objects. However, what I would like to know, is, does SQL Server suffer a performance hit from having a...

MySQL Type for Storing a Year: Smallint or Varchar or Date?

I will be storing a year in a MySQL table: Is it better to store this as a smallint or varchar? I figure that since it's not a full date, that the date format shouldn't be an answer but I'll include that as well. Smallint? varchar(4)? date? something else? Examples: 2008 1992 2053 ...

How to incorporate SQL_CALC_FOUND_ROWS and FOUND_ROWS() into existing web application

I just read about mysql's SQL_CALC_FOUND_ROWS and FOUND_ROWS() which helps you get the total result size of a previously executed query by dropping the LIMIT conditions. Now i want to use this feature in an existing web application. I have a few approaches in mind, but I'm not sure which is best: 1) Does PHP already have functions tha...

How can I set autoincrement format to 0001 in MySQL?

How can I make MySQL auto increment in 4 digit format? So instead of '1' make '0001'? ...

Count rows added today, yesterday...and other times

I was given good direction to solve a problem today from here but I got stuck in trying to follow this direction. I would like to retrieve a count for all rows from a table for the past 30 days using my date field. I populate these fields using "now()" and they are in the format "2009-03-04 14:58:01". I need a count for the rows added...

Recommend security training for PHP/MySQL web developer

Know any good courses, online or perhaps otherwise, you'd recommend to a relatively new PHP/MySQL web developer to get her up to speed on security vulnerabilities? It would be nice if it was fairly thorough and went beyond basic stuff like sql injection. Ideas? Edit: Thanks for the really great links and information, but I'm also loo...

Why does this mysql query give me garbage results?

Im trying to get the total amount of points a user has, as well as current month's points. When a user gets a point, it gets logged into the points table with a timestamp. Totals ignore the timestamp, while the current month's points looks for the points with the correct timestamp (from the first day of the month). SELECT user_id, user_...

Selecting with subqueries in MySQL (Subqueries with ANY, and IN)

Thanks for the great answers! For More Information More info on MySQL IN comparison operator Joining Tables Subqueries with ANY, IN, and SOME This is hard to explain, so lets set the stage... userActions userGroupMap +------+--------+ +------+-------+ | user | action | | user | group | +------+--------+ +------+----...

SQL: Need to limit the resultset based on a subquery

...

Pros and Cons of the MySQL Archive Storage Engine?

For a website I am developing, I am going to store user activity information (like Facebook) and HTTP requests to the server into a MySQL database. I was going to use InnoDB as the storage engine; however, I briefly read about the Archive storage engine and this sounds like the way forward for information which is only Inserted or Selec...

Help with a nested query in MySQL

I have a Student_classes table like following: Student_classes Student Classes Jon w. Algebra Jon w. Algebra Jake English Scott Spanish Scott Korean Neo Physics Anderson Chemistry Anderson Psychology i need to fetch data from this table so that. if student, classes pair occur...

Oracle performance of schema changes as compared to MySQL ALTER TABLE?

When using MySQL MyISAM tables, and issuing an ALTER TABLE statement to add a column, MySQL creates a temporary table and copies all the data into the new table before overwriting the original table. If that table has a lot of data, this process can be very slow (especially when rebuilding indexes), and requires you to have enough free...