mysql

unknown column in where... its defined right there!!!

Hi guys, im using this query SELECT DISTINCT pr.competitorID AS compID, pr.age, CONCAT(pr.firstname, ' ', pr.lastname)AS name , (SELECT participation_reports.points FROM participation_reports WHERE participation_reports.heatEventID=1 AND participation_reports.competitorID=compID LIMIT 1) AS '100m' , (SELECT participation_reports.poi...

Managing picture tags in SQL

I would like to build a database of pictures. Each picture may have 1 or more tags, for example: Paris, April 2010, David. How would you store this information ? I thought to have a Files table with 1 row per file, and one of the columns would be Tags IDs separated by commas, for example: 2,4,14,15 In other table called Tags I thought ...

How to truncate the text returned for a column in a MySQL query

I have a table in a MySQL database that I am running simple SELECT queries on (for quick diagnostics/analysis - since I am not running phpmyadmin on the server - for security reasons). I would like to be able to truncate the returned data using something like this: select id, LEFT(full_name, 32), age FROM user where user is a table t...

explain command usage

hi, i ran the explain command on my main table in mysql.it showed like id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE xyz ALL NULL NULL NULL NULL 1722 Using where does this affect the performance of the site? like when i so a select clause ? i have ...

Can't access mysql table, get a message that it has crashed

I have a a mysql table that I can't access, I get the following error ERROR 1194 (HY000): Table 'menu_config' is marked as crashed and should be repaired How do I go about in fixing this? And will all my data be lost? ...

MSSQL to MySQL API conversion layer

Hi, I'm looking for a program that can emulate, impersonate a MSSQL server and convert and write the queries to a MySQL database. Thus allowing me to configure client applications developed for MSSQL database systems only, to connect to the emulator and thus writing and reading the MySQL based records. Any help will be highly appreciat...

Keep only 10 records per user

I run points system on my site so I need to keep logs of different action of my users into database. The problem is that I have too many users and keeping all the records permanently may cause server overload... I there a way to keep only 10 records per user and automatically delete older entries? Does mysql have some function for this? ...

Script to update your production DB from test DB

On my local computer I have a test environment running XAMPP. I am working on a PHP / MySQL application. Now I often make changes to the local website, but when I want to upload I have to do a lot of work. This is what I do now. I export my local DB trough phpMyAdmin I clear my remote DB I import the exported DB. Sometimes the DB is k...

Can I do pivot with mysql 5.1?

Can I do pivot with mysql 5.1? (or emulate it somehow). ...

mysql index size and duplicacy questions

Hello, I have a few general questions about database Index. Answers to any question are awaited: How to calculate total memory size occupied by an index. And is the size of index directly proportional to its Cardinality ? Do we need to index primary key, or is it indexed by its own. And how will it effect the memory and processing spe...

First project for resume

Which project is better to write the for job ( Developer PHP )and then not be ashamed to refer to on his resume? What functions should it feature ? If anyone has a ready, detailed terms of reference for similar Drafts, please point me in that direction, or if you have the opportunity, show a sample list of what to do in such projects. ...

Accidentally ordered a PHP6 book for learning PHP

I want to learn PHP so I ordered a book about it called "PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide" I stumbled upon the php.net website and found out the latest thing released was PHP 5.3.2 The describtion of the book says that "[...] 20% or so of the material requires version 6 of PHP." DID I SCREW UP AND SHOULD...

Emulate auto-increment in MySQL/InnoDB

Assume I am going to emulate auto-increment in MySQL/InnoDB Conditions Using MySQL/InnoDB The ID field don't have unique index, nor it is a PK Is it possible to emulate only using program logics, without table level lock. Thanks. ...

Show status in mysql

Hi, What does this show status illustrate in mysql? Aborted_connects and Connections from this query: SHOW STATUS LIKE '%connect%' Is it telling that DB connections are not closed properly? ...

MySQL queries slow after a DELETE

I have a two part PHP script. The first that deletes some rows in the database The second that triggers SELECT queries The second script alone runs in about 0.2 sec. When both parts are processed, the second part takes 5 sec. The next time the second script runs alone, it's back to 0.2 sec. Any clue? ...

Is it better to do a select count then if before doing a delete or just blindly call delete?

I'm looking for a best practice / thoughts on if it is better to do a select count and checking if the result is > 0 before calling a delete or if it would be better to just blindly fire a delete statement at the database even if the data doesn't exist. In our case most of the time data will NOT exist. So what is better: Option 1: c...

Optimized datatypes + simple database design

i am using a simple database design and i think the best database example is e-commerce, because it does have a lot of problems, and its familiar to cms. USERS TABLE UID |int | PK NN UN AI username |varchar(45) | UQ INDEX password |varchar(100) | 100 varchar for $6$rounds=5000$ cr...

Using Java (HTMLUnit) to Scrape a Web Page then Write Results to a mySQL Database

I've been able to use Java and HTMLUnit to scrape a web page, however I'm unsure how I can get this to write the resulting data to a MySQL database on a remote hosted server. I also need this to happen at regular intervals (perhaps once a day) if possible, without having to manually run the program. Is this possible and can I have any g...

updating the few highest rows in a table using mysql 5.1.41

I have a table with several hundred rows. I want to take the top 20 based on the value of column num and replace num with a number. What I tried to do (which didn't work) was: UPDATE table SET num = 95 WHERE id IN (SELECT id FROM table ORDER BY id DESC LIMIT 20) Any suggestions? ...

PHP & MySQL - Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

I was wondering how can correct the error I keep0 getting listed below. I get the following error. Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given on line 159 Line 159 is $foundnum = mysqli_num_rows($run); Here is part of the PHP & MySQL code. mysqli_select_db($mysqli, "sitename"); ...