mysql

SQL: dealing with unique values in the table when UNIQUE key constraint isn't applicable

What you do when you need to maintain a table with unique values when you can't use UNIQUE constraint? For example, I use MySQL and want to map my urls to ids. So I create a table: CREATE TABLE url (id INTEGER PRIMARY KEY AUTO_INCREMENT, url VARCHAR(2048)); The problem is that mysql doesn't allow unique field bigger than 1000 bytes. ...

Apache webserver crashing!

Hello, I am using a Wampserver 2.0 for database-web development. When i ran the following the php code which is embbeded in my html form, the server crashes meanwhile other php processes on different pages are responding effectively. I have checked my apache error log and saw the following message: [Fri Oct 22 11:37:04 2010] [error] [c...

MySQL database structure for a questionnaire

Hello there! I am willing to build a small questionnaire and I was just wondering, how the database structure should look like... I mean I have different possibilities for the answers - checkboxes, drop-down-menus, input-boxes, etc., so as for the questions. And how should I save the questionnaires itself? Should I make for each differen...

mysql query: going crazy

Hi all! I'm having some trouble running a query on a table like this: +-----+---------------------+-------+------+ | id | paid_date | amount| type | +-----+---------------------+-------+------+ | 204 | 2010-10-22 05:12:54 | 1000 | 0 | | 205 | 2010-10-22 05:13:12 | 1000 | 1 | | 206 | 2010-10-21 05:13:44 | 1000 | 0...

MySQL ORDER BY question.

How can I add an order by users_friends.date_created that governs both select queries. Here is my MySQL code. (SELECT A.user_id, A.friend_id, B.username, B.avatar FROM users_friends AS A INNER JOIN users AS B ON A.friend_id = B.user_id AND A.user_id = 3 AND A.friendship_status = 1) UNION (SELECT A.friend_id, A.user_id, B.username,...

Have I understood Database design correctly?

Have I understood db design correctly? A user can have one or multiple professions Each profession has multiple qualifications associated with it A user can have none or all of these qualifications. Are there any improvements that should be made? simplicity should be maintained. I intend to shorten table and column names. UPDATE:...

Audit logs in MySQL and PHP

Hi, My application has a series of forms. I want to track the following for each of the data fields in a form: Time of change, who changed it, old data and the new data Any suggestions on a solution for this? In my implementation of the database, the structure of a form is defined as DATA in a table, not by it's columns. For example ...

mysql fetch previous or next record order by anyother field name and not by using order by id

Hi, I am displaying a list. The user can edit any item. I am displaying next previous buttons which when clicked it dynamically fetches the next previous records form db. no page reload. this is working well with id. like http://stackoverflow.com/questions/3780642/how-can-i-get-next-and-previous-field-id-with-php-from-mysql and http:...

insert multiple values using a query as array

Hello, i'm trying to insert multiple data using a query, i've tried the implode function, the while loop, for loop, but still can't be done.. can u help plz well i've a combobox box for selecting course name, created a function to get its ID and assign a variable. supose i'm a manager of a department and need to assign all staff below ...

Perl MySQL - How do I skip updating or inserting a row if a particular field matches?

I am pretty new to this so sorry for my lack of knowledge. I set up a few tables which I have successfully written to and and accessed via a Perl script using CGI and DBI modules thanks to advice here. This is a member list for a local band newsletter. Yeah I know, tons of apps out there but, I desire to learn this. 1- I wanted to avo...

MySQL syntax error

Hello, I get the following syntax error 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 '* ,MATCH(city) AGAINST ('""' IN BOOLEAN MODE) FROM `` WHERE MATCH(city) AGAINST ' at line 1 The corresponding code for this error is the following...

Remove duplicate text from field

I am wondering if it is possible to remove duplicate text using a mysql query from one field, or if a problem like this would be better solved using PHP. I have a database where users enter tags which can be searched upon. I have noticed that some tags have synonyms which I want to add to the field, but in some cases the synonym already...

High Number of MySQL Temporary Disk Tables

Hi, We have noticed that MySQL is reporting a very high number of temporary disk tables (over 10,000) this is reported by Server Density. Were trying to understand a bit more about this. Why are temporary disk tables created by MySQL? What impact do they have on performance? Are they ever removed by MySQL or will this number just inc...

Extremely simple MySQL Query not working

Im a little puzzled here, can someone just look over this query and tell me am i doing anything wrong? SELECT d.* FROM as_downloads d LEFT JOIN as_categories c ON (d.download_category_id = c.category_id) WHERE d.download_category_id != -1 LIMIT 30 Fetching the rows from the as_downloads table but not joining the categories table.. Th...

How to match junk characters in mysql database with arabic letters with PHP and MYSQL.

Hi all, My question in brief here: The site is developed with PHP as front end and mysql as backend. I am registering in my site by entering the arabic letters. And the value also inserted in mysql database. But it is not in the format what i entered. It looks like junk words. Now my problem is when i try to login i can't able to mat...

reverse match of multiple words

Thanks for reading this. Hope you can help me. When I have a Mysql table with these row values id| search ======== 1| butterflies 2| america 3| birds of america 4| america butterflies how can I tell which rows have all the words in column 'search' occuring in the string "butterflies of america", regardless of the number or order of the...

Return 0 if field is null in MySQL

I am trying to pull data from multiple tables to do accounting computation determining credit balance on customer accounts. If any of the total fields are NULL, I want MySQL to return 0 for those fields. Here is what I have: SELECT uo.order_id, uo.order_total, uo.order_status, (SELECT SUM(uop.price * uop.qty) FROM uc_order...

Why are the date fields in my rails object / model evaluating to nil when I can clearly see that they are not?

I'm using ruby 1.8.6 and rails 1.2.3 (ancient but I'm debugging an old app) A model called Payperiod has attributes begindate and enddate and after importing the db, the dates are all there (apparently) But in the console and in the app, the date attributes eval to nil. Why? Below is some code pasted from the console: pp = Payper...

Capitalize names properly in SQL

I would like to capitalize names properly, which in this case means: The first letter is capitalized. The first letter after a space is capitalized ('Van Helsing', not 'Van helsing') The first letter after a dash is capitalized ('Johnson-Smith', not 'Johnson-smith') No other letters are capitalized. The first and last requirements ar...

Posting PHPBB Forum Thread/Post info in a website

Hey there I am trying to extract, say, the latest/most recent 5 threads in the X section of my Forums and have it 'posted' on my website with a link so the viewers can go directly to the thread instead of having to browse the forum or what not. I've seen and read some tutorials online but...in all honesty, phpbb seems like a mess to me...