mysql

session management: problem displaying username in the header

hi, I am working on a simple login and logout module for my website without any security. I am using wamp on a windows xp machine. I am creating session when a user submits the login informaton it redirects to a process.php file which creates the session variables and starts session. Now if the login is successful user is redirected to ...

MySQL compare DATE string with string from DATETIME field.

Hello. I have a question: Is it possible to select form MySQL database by comparing one DATE string "2010-04-29" against strings that are stored as DATETIME (2010-04-29 10:00) ? I have one date picker that filters data and I would like to query the table by the DATETIME field like this: SELECT * FROM `calendar` WHERE startTime = '2010-...

Unable create a table - ERROR 1064 (42000): You have an error in your SQL syntax

I'm trying to execute this simple command: create table foo (clo int primary key unsigned auto_increment); But I get this error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned auto_increment)' at line 2 ...

Should I use two queries, or is there a way to JOIN this in MySQL/PHP?

Morning y'all! Basically, I'm using a table to store my main data - called 'Code' - a table called 'Tags' to store the tags for each code entry, and a table called 'code_tags' to intersect it. There's also a table called 'users' which stores information about the users who submitted each bit of code. On my homepage, I want 5 results r...

Deleting certain rows based on the count of a column in the mysql database

Hi, I have a very large database with about 120 Million records in one table.I have clean up the data in this table first before I divide it into several tables(possibly normalizing it). The columns of this table is as follows: "id(Primary Key), userId, Url, Tag " . This is basically a subset of the dataset from delicious website. As I s...

Sorting by custom field and fetching whole tree from DB

Hello everyone, I am trying to do file browser in a tree form and have a problem to sort it somehow. I use PHP and MySQL for that. I've created mixed (nested set + adjacency) table 'element' with the following fields: element_id, left_key, right_key, level, parent_id, element_name, element_type (enum: 'folder','file'), element_size. ...

MySQL: Using of coma separated ids in a table column and group_concat

In a table, there is a column that contains ids separated by comas ex: "159,167" I want to do the equivalent of a join between this table and the table that contains those ids. ex: TableA TableB id desc id desc tableAids stock 1 test1 1 abc 1,2,3 1 2 test2 2 def 1,2 0 3 te...

Help with MySQL query... Need help ordering a group of rows

I can tell it best by explaining the query I have, and what I need. I need to be able to get a group of items from the database, grouped by category, manufacturer, and year made. The groupings need to be sorted based on total amount of items within the group. This part is done with the query below. Secondly, I need to be able to show ...

Complex Join - involving date ranges and sum...

I have two tables that I need to join... I want to join table1 and table2 on 'id' - however in table two id is not unique. I only want one value returned for table two, and this value represents the sum of a column called 'total_sold' - within a specified date range (say one month), however I want more than one date range at the same tim...

serializing objects in C++ and storing as a blob type in mysql

I am using mysql/C++ connector to connect to a mysql database. I have some complex data structures so I need to serialize those and save in the database. I tried something like the following. vector<int> vectorTest(10,100); istream *blob = NULL; ostringstream os; int size_data = sizeof(vector<int>); blob = new istringstream((char*)&v...

PHP and MySQL - posting double entries

Hello, I am trying to post a form with two fields (name and email) into a MySQL table. On local server (my laptop), it works just fine. But on production server, it is posting twice! I can't figure out why. Here is the code: $name = ucwords(strtolower(trim($_POST['name']))); $email = strtolower(trim($_POST['email'])); $mysqli = ...

mysqldump generating an empty file

Hello all! Im trying to use mysqldump like below: mysqldump -hlocalhost -uadmin -padmin shop> D:\b2\shop3.sql When i execute it in command prompt, the file shop3 is generated with all the tables from the shop database. But, when I use it in my php file like below, it generates an empty file. $cmd = 'mysqldump -hlocalhost -uadmin -pad...

Filter by current date in MySQL

How to pass the current date to a query in mysql like such query: select from Dailytimesheet dailytimesheet where dailytimesheet.TrackingDate="2010-05-03" ...

mysql ON DUPLICATE KEY UPDATE

Hi-- I'm stuck on a mySQL query using ON DUPLICATE KEY UPDATE. I'm getting the error: mySQL Error: 1062 - Duplicate entry 'hr2461809-3' for key 'fname' The table looks like this: id int(10) NOT NULL default '0', picid int(10) unsigned NOT NULL default '0', fname varchar(255) NOT NULL default '', type varchar(5) NOT NULL default...

A very interesting MYSQL problem (related to indexing, million records, algorithm.)

This problem is pretty hard to describe and therefore difficult to search the answer. I hope some expert could share you opinions on that. I have a table with around 1 million of records. The table structure is similar to something like this: items{ uid (primary key, bigint, 15) updated (indexed, int, 11) enabled (indexed, tinyin...

MySQL query does not return any data

Hi, I need to retrieve data from a specific time period. The query works fine until I specify the time period. Is there something wrong with the way I specify time period? I know there are many entries within that time-frame. This query returns empty: SELECT stop_times.stop_id, STR_TO_DATE(stop_times.arrival_time, '%H:%i:%s') as stop...

Surgical slave reads for Ruby on Rails, mulitple databases.

Greetings, I'm currently working on a multiple database rails application. I want to off load the SELECT queries on to the slave databases for only SOME of the databases or specific models. The issue is that in places, we swap out the current database connection and put in a different one for a short time; to load fixtures or to hand...

limiting the rate of emails using python

I have a python script which reads email addresses from a database for a particular date, example today, and sends out an email message to them one by one. It reads data from MySQL using the MySQLdb module and stores all results in a dictionary and sends out emails using : rows = cursor.fetchall () #All email addresses returned that ar...

Query to find all bars that sell three different beers at the same price

Query to find "All bars that sell three different beers at the same price?" My Tables are Sells(bar,beer,price) - bar - foreign Key.. Bars(name,addr) - name primary key. I thought of something like this but that dosent seem to work ... Select A.bar As bar , B.bar as bar From Sells AS A, Sells AS B Where A.bar = B.bar and A.b...

What does the "Add DROP TABLE / VIEW / PROCEDURE / FUNCTION" checkbox do in phpmyadmin

Under the structure tab, when EXPORTing a database using phpmyadmin there is a check box labeled: Add DROP TABLE / VIEW / PROCEDURE / FUNCTION What does this do? ...