mysql

Creating same login page for different users

I have one login page used by all users on the site. However, once they login, they go to different pages. The users are currently stored in different tables in the database and I need to check to see which page I should navigate to. Does this mean that I should add all these users to a single table and specify the kind of user? W...

How to get all privileges back to the root user in MySQL?

I am using MySQL. My root user doesn't have all privileges. How can I get all privileges back to the root user? How to do it step by step? ...

Mysql - selecting year from a unix timestamp

I am using this: SELECT FROM_UNIXTIME(my_unix_timestamp_column, '%Y') AS year FROM table_name WHERE year = 2009; but it gives me an error: Unknown column 'year' in 'where clause'SELECT FROM_UNIXTIME(my_unix_timestamp_column, '%Y') AS year FROM table_name WHERE year = 2009 Both "my_unix_timestamp_column" and "table_name" are correct...

Proper syntax for MySQL 5.0.x FEDERATED table creation?

So I'm trying to create a federated table using the syntax from the docs. Following this, I've created a table like so: CREATE TABLE `federated_table` ( `table_uid` int(10) unsigned not null auto_increment, ..., PRIMARY KEY (`table_uid`) ) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://user:[email protected]:3306/';...

How can I restore the MySQL root user’s full privileges?

I accidentally removed some of the privileges from my MySQL root user, including the ability to alter tables. Is there some way I can restore this user to its original state(with all privileges)? UPDATE mysql.user SET Grant_priv = 'Y', Super_priv = 'Y' WHERE User = 'root';# MySQL returned an empty result set (i.e. zero rows). F...

MySQL/C++ and Prepared Statements: setInt always 0

I'm using the MySQL Connector/C++ library to insert values into a database table. I'm following the examples at http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html almost exactly. However, I can't seem to get prepared statements to work with value placeholders. sql::mysql::MySQL_Driver* driver = sql::mysql::MySQL...

Empty set while selecting data in MySQL relational database

Hi! I have some relational MySQL database with dozens of tables... My query is 1000 ft long and selects data from almost all the tables... I also have my 'main' table, and all other tables are referring to that one. When I enter one row in my main table and when I create all relations for that row in other tables my query works fine. How...

Most efficient way to order a list by a preset random.

I have a online PHP system where users vote different awards for their friends, however I am finding that the awards in the middle of the page and at the bottom get less votes overall. I would prefer this to be evenly distributed so came up with ordering the list of awards by random to make it different each time you load the page. This...

Tsung Erlang function (dynvars) - escaping quotes

New to Tsung and Erlan and have run into an issue I haven't been able to find answer to. I'm using erlang-mysql-driver in a Tsung dynvars Erlang function and I seem to be having a problem with escaped quotes. I'd like to do something like this: <setdynvars sourcetype="eval" code='fun({Pid,DynVars})-> ...

Move Multiple Tables into One, with Addition of Extra Field Value

I have 31 separate tables (actually I have 365, but lets keep this simple) in a MySQL database, each containing data for a given day. The tables are (badly) named based on the day. Example: island01Aug07 island02Aug07 island03Aug07 island04Aug07 ... island31Aug07 I would like to combine all the tables into one master table: island_...

Get the greatest value into serialized data with php into mysql column

Hi What is the way to get the greatest value into a serialized data. For example i have this in my column 'rating': a:3:{s:12:"total_rating";i:18;s:6:"rating";i:3;s:13:"total_ratings";i:6;} How can I select the 3 greatest 'rating' with a query? thanks a lot ...

SQL query return True/False

I am working with an existing architecture which populates fields on a form with things from the database. The form is entirely database driven and is done in PHP and MySQL. The problem is that the database table that holds the form elements has a field for the query that will return a result set that will be used to populate the select...

Using two different databases with identical hibernate mapping files

Basically the idea is to use the same hibernate mapping files for two different underlying databases. In production the underlying database is MySQL5 and for testing purposes I'd like to use Apache Derby - in order to avoid setting up and maintaining various MySQL databases for testing purposes. I hoped that just switching the DataSour...

MySQL Strange Insert Error

I am getting strange error while inserting data into mysql table column. Details: Create Table Statement: CREATE TABLE `product_offer_line` ( `object_id` int(19) NOT NULL default '0', `snapshot_id` int(19) NOT NULL default '0', `domain` varchar(255) NOT NULL, `description` varchar(255) default NULL, `name` varchar(255)...

MySQL error, I can't see what's wrong

Hello, I am using this code to enter update user permissions on a web app: $updaters = array(); for ($i = 1; $i <= 24; $i++){ if (isset($_POST['permsA['.$i.']'])) $updaters[] = '`'.$i.'` = \''.mysqli_real_escape_string($db, $_POST['permsA['.$i.']']).'\''; } $insert = mysqli_query($db,'UPDATE `tbl_perms` SET '.implode(...

Random MySQL row with PHP- low system resources.

I'm looking to get a random row from MySQL without using too much time or resources on the system. I don't care about weather the code given is PHP or MySQL based, however please note there are 'gaps' in my table. My table columns are 'id' (Primary key, auto increment), varchar, int, int I'd like it to be as random as possible ...

Adding an ad to a mysql database; Point me in the right direction please...

Currently, I have an 'add your ad here' page, with a form. Now, the user must select what category he will want to post an ad into... So I have a table for each category in mysql. Now my question, how would I make each ad unique, with an ID nr? If I have several tables, the 'auto increment' might turn out to be the same in some ads, a...

which is faster, mysql database with one table or multiple tables?

On my website you can search 'ads' or 'classifieds'. There are different categories. Would the searches be faster with multiple tables, one for each category, or wouldn't it matter? We are talking about around 500 thousand ads. If it won't slow down the search, please explain yourself so that I understand why it won't, because it seem...

Lua connecting to MySQL

I have a Lua web app. I would like to connect and query my MySQL database. I've googled and etc and have not found a good way to do so from Lua. Any idea how I can connect and query my MySQL from within my Lua web app? Thanks ...

Exporting database dump via phpMyAdmin to MS SQL

When I use the phpMyAdmin export, it has an option for MS SQL export compatibility. However, the resulting file includes many non-MS SQL compatible items, such as mediumtext and enum datatypes. How do I work around this issue? ...