mysql

Mysql INSERT SELECT problem (funny)

I have a table with primary key id AUTOINCREMENT and some other attributes. I have many rows with attribute lang='en'. and I do DELETE FROM ".MY_PRF."form WHERE `lang` <> 'en' I want to COPY all them changing lang to 'cz' I use: INSERT INTO form (`lang`, `caption`, `type`) SELECT 'cz', `caption`, `type` FROM form WHERE lang = 'e...

Create table query

I want to create a table for making a comment box. I was told that I should be wary of sql injection (dont even know what that means). So I thought I should ask around at SO. my requirements are: Comments table a comment row ~400 chars aid -> every comment should be linked to an aid. duplicates should be allowed. means aid = 21, can...

Need mySql query

I have n number of users with different articleId. If I pass the articleId, I want to get the results like how many different users viewed that article. Table 1: recId userId articleId ----- ------ -------- 100 1001 1 103 178 2 106 475 3 107 327 4 108 567 5...

SQL query - group by timespan in MySQL

I have a table containing the following details: date_info info 2009-06-23 1 2009-06-24 2 2009-06-25 20 2009-06-26 14 2009-06-27 17 2009-06-28 5 2009-06-29 10 2009-06-30 2 etc. I would like to group the info coloumn by occurrences per week and month, like so: 2009-06-01_2009-06-07 XXX 2009-06-08_2009-06-14 XXX Grouping by...

check if fieldvalues exist?

i want to check if a column contains any fieldvalues in a table. cause i want to get the fieldvalues in a column and do something with them, but first i have to check whether they exist or not. i have tried: $query = "SELECT anonymous_username FROM users"; $result = mysqli_query($conn, $query) or die ("Couldn't execute query: " . mysq...

What's the deal with Rails' alter_table method?

I've been using sqlite3 for my database under development and my app has gotten complex enough that it's a bit slow to work with. I've just switched to MySQL and run rake db:create ; rake db:migrate and one of my migrations failed with the following error message: undefined method `alter_table` for #<ActiveRecord::ConnectionAdapters::M...

Trying to join 2 tables, wont work

I want a list of all threads of the forum ID I'm viewing, but I also want to get information about the forum I'm viewing, like name and description. My query wont work: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in forum.php on line 11 How would I join in my forums table in this query? $tresult = m...

drools persistence with mysql, can't get process instance.

I'm stumped. I'm trying to implement persistence with Drools-flow, and I'd like to grab the value of a property on a workitem / processinstance, but everytime I try to get the workitem or process instance I end up with the stack trace below. I'm walking through the source and from what I can tell, this happens anytime I try and grab a ...

How can i tell if a MySQL query returned nothing in PHP?

Question title says it all. I'm using PHP5 and MySQL. EDIT: I'm using mysql_...() functions. ...

Load Data Infile + Disable/Enable Keys Performance

I have a table with approximately 7 million rows. Once a day, I need to bulk import around 200,000 new rows into this table. To do this, I am first disabling keys on the table, using LOAD DATA INFILE, and then re-enabling keys on the table. The problem I am having is with the ALTER TABLE my_table ENABLE KEYS statement. It takes arou...

help with deleting relational tables

I have four tables: users: id, thread_id threads: id, language_id posts: id, user_id, language_id languages: id USERS.thread_id is a foreign key to THREADS.id, POSTS.user_id is foreign key to USERS.id and POSTS.language_id foreign key to LANGUAGES.id. I can't delete an user because the POSTS.user_id will throw a foreign key constrai...

connect to remote mysql database through ssh using java

How can I connect to remote MySQL database through SSH from java application. I'd appreciate a small code example. ...

Why should I free the result of PHP and MySQL?

Why should I free the result of PHP and MySQL using mysql_free_result()? And what is the difference whether I free the result or not? Should I always free the result from a MySQL query result specially in CRUD? Thanks for answering my questions? ...

Begginer Mysql 5.0 Stored Procedure Syntax question

I'm just trying to create my first mysql stored procedure and I'm trying to copy some examples almost directly from the documentation, but it isn't working: mysql> delimiter // mysql> CREATE PROCEDURE ghost.test (OUT param1 INT) INSERT into admins SELECT COUNT(*) FROM bans; END// ERROR 1064 (42000): You have an error in your SQL syntax;...

Mysql Command to view the definition of stored procedure ?

Mysql command to view the definition of stored procedure . I know sp_helptext is the command in MS-Sql to display the definition of stored procedure , is there a similar command in Mysql ? I am not looking for SHOW PROCEDURE STATUS which display the list of the procedures available for the particular database in mysql . Thanks ! ...

MYSQL Query TAKING user's participation place with quantity of all other participants

Hi, I am making a website where users add the place where they have visited. There is 4 main tables users (user_id,name ) places (place_id,type_id,place_name, city_id) user_place (user_id,place_id, date ) city(city_id,city_name) Now I need to take with one query all the places which are type of 2 (where type=2) where the given user...

mysql insert if row does not exist already in a table with NO UNIQUE FIELDS

Looking for a while now already for how to accomplish this. Seems that all solutions need unique fields with indexes. ...

MySQL-python 1.2.3 and OS X 10.5: 64- or 32-bit?

I've been happily using Django and MySQL in development on an existing machine running OS X 10.4 Tiger, and have set up a similar environment in 10.5 Leopard on a new 64-bit MacBook, with a working MySQL and Python 2.6.4. However, now I want them to communicate, easy_install MySQL-python gave ld warnings that the file is not of the requ...

Stored procedure not working in MYSQL

Hi All, I have created the following stored procedure but not working as expected.....Some error line 3 DELIMITER $$ DROP PROCEDURE IF EXISTS mytest.sp_insert_request $$ CREATE [email protected] PROCEDURE sp_insert_request(@RequestID varchar(250) = null, @Status varchar(45)= null,@Status_message varchar(9180)= null,@time_of_...

MySQL foreign keys recursive

I have a "categories" table that has a structure: categoryId parentId categoryName This table represents categorized tree structure where parentId is actually a pointer to categoryId. Is it possible to put a foreign key RESTRICT to parentId which points to categoryId so that I disable deletion of children nodes? ...