mysql

Friendship System Sql Structure & Query

Hello. I am coding a friendship system and it has two tables. members id username password friends id user_id friend_id status Let's say that i want a query that can select the friends IDs of the member $userId how possible to make this in one query? I found a solution which is to make 2 queries. The fist selects the friends W...

Low MySQL Table Cache Hit Rate

I've been working on optimizing my site and databases, and I have been using mysqltuner.pl to help with this. I've gotten just about everything correct, except for the table cache hit rate, no matter how high I raise it in my.cnf, I am still hitting about 0% (284 open / 79k opened). My problem is that I don't really understand exactly ...

Join 2 Tables and display everything

I have 2 simple tables: table a: id | txt ---+---- 0 | aaa 1 | bbb 2 | ccc table b: id | tel ---+---- 0 | 000 2 | 111 I am trying to join 2 tables like this: SELECT a.*,b.* FROM a,b WHERE a.id=b.id It works, but, if there is no entry in the "b" table it wont show anything. what the sql shows is something like this: ...

sql statement to retrieve a list of results (from other table) for a given record?

I have the following schema: TABLE bands -> band_id -> property1 -> property2 -> ... TABLE tracks -> band_id -> track_id The tracks table typically maps a single band_id onto multiple track_ids (there are multiple tracks for each band). My goal is to build, for the bands that match certain conditions (in terms of property1, property...

MySQL, DELETE Query with a Join

Can someone help me understand what's wrong with this query: DELETE FROM noteproject INNER JOIN note ON noteproject.noteID = note.noteID INNER JOIN person ON note.personID = person.personID WHERE noteID = '#attributes.noteID#' AND personID = '#attributes.personID#' ...

Importance of varchar length in MySQL table

I have a MySQL table where rows are inserted dynamically. Because I can not be certain of the length of strings and do not want them cut off, I make them varchar(200) which is generally much bigger than I need. Is there a big performance hit in giving a varchar field much more length than necessary? ...

PHP myAdmin - Change Field Order (Move Up Or Down)

How do I change the order of my table fields without deleting the field and re-inserting it, using PHP myAdmin? ...

Importance of backtick around table name in MySQL query

In MySQL queries, how important is it to put backticks around a table name. Does it have something to do with security? Are MySQL injection attacks possible through the table name if the table name is created dynamically in PHP based on user inputs? ...

Adding fields to optimize MySQL queries

I have a MySQL table with 3 fields: Location Variable Value I frequently use the following query: SELECT * FROM Table WHERE Location = '$Location' AND Variable = '$Variable' ORDER BY Location, Variable I have over a million rows in my table and queries are somewhat slow. Would it increase query speed if I added a...

change MySQL field type if field exists

I have the following query: ALTER TABLE table CHANGE field1 field1 INTEGER Is there anyway that I can add some sort of if exists to this statement so that MySQL will make sure that field 1 exists before attempting to change its field type? ...

xml to mysql database

I have a question. Does anyone have a working php script which can parse a XML file to a sql database? I have searched for some scripts and didn't find anything what looks like I can edit it to my needs. Any help would be great! ...

Is it a good practice to put the tables of different versions of a website(no data sharing among these versions) in one database?

I am developing a website. There is an English version, Japanese version and Chinese version. Different version is for different language speakers. If you are a registered user of the English version, and you want to use the Japanese version, you still need to register on the Japanese version. So should I create one database and put all ...

user registration php

<?php include"include/connection.php"; $checkusername=mysql_query("SELECT * FROM employer WHERE eusername='$username'"); if (mysql_num_rows($checkusername)==1) { echo "username already exist"; } else { $query = "insert into employer(efname,elname,egender,eemail,eusername,epwd,eadd,ephone,ecity,ecountry) values ('".$_POST['first_name...

How to automatically backup ALL mysql databases into sql statement?

MySQL Administrator> Backup Project. It is a great tool to allow you to select databases, and schedule it. However my issue is: Today got a few new websites (new database created) Tomorrow got a few more new websites (new databases created) In this case, I have to always go into Backup Project> Select those remaining schema not in the...

jquery - send string to php to safe it in mysql

Hi, i got this script, which i found in the web: <script type="text/javascript"> $(document).ready( function () { $('a.closeEl').bind('click', toggleContent); $('div.groupWrapper').Sortable( { accept: 'groupItem', helperclass: 'sortHelper', activeclass : 'sortableactive', hoverclass : 's...

Python with MySQL on Windows: installation errors

I tried to run the following command, in the folder of my Django project: $ python manage.py dbshell It shows me this error: $python manage.py dbshell Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "C:\Python25\lib\site-packages\django\core\management\__init__.py", lin...

jquery stops insert into database

Hello all, i have made this script but then i press submit the jquery animation start but it will not submit it into the database with PHP :S. Here is my script http://pastebin.org/68943 Thanks ...

Select the newest entry based on other entries with the same values?

Lets say I have a table with some data like the following: ID text OtherID _______________________ 6 text1 24 7 text2 24 8 text3 24 9 text1 25 10 text2 25 As you can see I have multiple entries with the same OtherID. what would be an sql statement that would select only the newe...

Ways to export Tables/Views from mySQL Database to printer friendly format (other than phpMyAdmin)

I've created a bunch of views in a database and I'd like to export them to pdf. However phpmyadmin lets me only put a title on each page and it's very limited to how i can layout the output. does anybody have some recommendations of software/scripts they used? ...

Row Rank in a MySQL View

I need to create a view that automatically adds virtual row number in the result. the graph here is totally random all that I want to achieve is the last column to be created dynamically. > +--------+------------+-----+ > | id | variety | num | > +--------+------------+-----+ > | 234 | fuji | 1 | > | 4356 | gala ...