mysql

How to schedule a mysql stored procedure in windows?

Need to schedule in windows 2003 server to run a MySql Stored Procedure weekly once. I tried with batch file but it dint work for me. Any ideas? Thanks in ADV. ...

num_row manipulation in mysql?

i have this function that brings me back a value by query a table in the database! the code: function recycle_check($recycle_id){ $query = "SELECT recycle_id FROM notes WHERE user_id = '".$_SESSION['user_id']."' and recycle_id ='$recycle_id'"; if(mysql_num_rows($query)== 0) return 0; else ...

Super Slow MySQL - Need Help!

I have a SUPER slow query, which I posted here: http://pastebin.com/E5sdRi7e. When I did an EXPLAIN, I got the following: id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL...

Buliding up a coldfusion query problem with like

I am trying to build a dynamic sql statement with this line <cfset SQL = "SELECT url, MONTH(event_date) AS months, YEAR(event_date) AS year, event_date, title from events where title LIKE '%#form.event_name#%' "> <cfquery name="results" > #SQL# </cfquery> Seems there is a problem with the like clause. Any ideas? Do I need to escape t...

MySQL - conditional SELECT

I have tables item and store (it's a store management system). item table has a column called store_id and another column called status. item.status can be 'sold' or 'unsold'. I need help writing a query which will do these things: select all items of all stores if a store has just one item and that item is 'sold', remove that item fr...

grab mysql result based on field values

Hi all, I am taking over designing a CMS from another programmer. As the site is filling up, we're finding loops in mysql queries causing long hangs. I have found a temp solution for this one, but am wondering if there is a quicker way of doing it? take the table (tracks resources): id resource click 1 res_1 192 2 res_2 12 ...

how does the retweet mechanism work on twitter?

I'm creating similar thing to twitter retweet function! This is my database table for tweets (status messages): ID || USER_ID || TWEET || RETWEET_ID || RETWEET_NAME || DATE What I'm trying to find out is, if the logged in user retweets something, when they refresh the page I don't want them to see the retweet button (because obvious...

How to use a LIKE query with CodeIgniter?

I want to run a query like this: SELECT * FROM table WHERE field LIKE '%search_term%' In CI you can bind parameters to queries, if you used field=? but this does not work for field LIKE "%?%". From debugging output it seems the query used is field LIKE "%'search'%". Is there an alternative way to do searching in CodeIgniter? ...

Email Alerts on saved searches, procedure and safety/performance tips&tricks?

I built an email alert for my users (now are only 2,000) so every night a crontab execute a php script that query the mysql to find matches with user's saved search. it's a classified website in my case, but i would like to learn in case i had to build something for bigger clients my concerns are: what happen if my user grow x10 or x...

sortable tag lists, in terms of popularity?

I want to implement a tag list, for instance, top ten tags used in the website. Are there any tutorials or articles that can help me to create this! For example: #topic (200 mentions) #topic (150 mentions) #topic (50 mentions) .... and so on.. ...

Python ejabberd Auth Script not responding to changes in Database

I have an authentication script in ejabberd (XMPP server) that based off of THIS LINK I have slightly modified the script so that instead of setting the variable out, it just returns true or false. I'm using Ubuntu, MySQL, ejabberd, and Python. I can authenticate all the records that are already on the database. But, when I add or re...

do i have to specify the database name in select statement while hosting?

Hi there, i am getting an error while querying this select statement. $comments = dbgetvar("SELECT SUM(CASE WHEN c.approve = '1' AND c.spam = '0' THEN 1 ELSE 0 END) AS approved, SUM(CASE WHEN c.approve = '0' AND c.spam = '0' THEN 1 ELSE 0 END) AS pending, SUM(CASE WHEN c.spam = '1' THEN 1 ...

How to develop a Client/Server/Host Remote Desktop Solution that can tunnel through Firewalls and NAT

Hi Everybody, Im starting a college in which i hope to develop (most of at least) a Java & JSP based remote desktop application that replicates Logmein's architecture. I would appreciate some ideas on how to implement this from a network & software perspective. The following diagram is a good representation - http://blog.donet.com/wp-co...

Remove duplicates in large MySql table

I have a question about MySql. I have a table with 7.479.194 records. Some records are duplicated. I would like to do this: insert into new_table select * from old_table group by old_table.a, old_table.b so I would take out the duplicated entries...but problem is that this is a large amount of data. The table is MyIsam. Thi...

PHP: SELECT ing 2 tables?

Hello. I have a activities page and a statusmessages page for each user. In activities it contains what the users have done, such as being friends with someone, commented on pictures and so. users_activities id | uID | msg | date In users_statusmessages, I got the statusmessages, the user creates. users_statuses id | uID | messag...

Search for value within BLOB column in MySQL

How can I search inside Blob column in MySQL for some values ? and Is that possible ? ...

MySQL skip one child level

I have a table that has location ids in parent child relationships. It is basically a hierarchy like: State -County --City The table maps the hierarchy with the following columns parentID childID type If I want to get all sub-locations for a given location that's straightforward, something like: SELECT childID FROM locatio...

return id of new record

Is there a way with Pear DB to return the ID of a newly INSERTED record? ...

Getting this query to work?

Heya!, I have the below query: SELECT t1.pm_id FROM fb_user_pms AS t1, fb_user_pm_replies AS t2 WHERE (t1.pm_id = '{$pm_id}' AND t1.profile_author = '{$username}' OR t1.pm_author = '{$username}' AND t1.pm_id = t2.pm_id AND t2.pm_author = '{$username}' AND COUNT(t2.reply_id) > 0) AND t1.deleted = 0 ...

Selecting columns in UNION

$queryActivities = mysql_query(" SELECT ua.status, ua.date, 'status' AS is_table FROM users_statuslog ua WHERE ua.uid = '{$showU[id]}' UNION ALL SELECT us.message, us.date 'wall' FROM users_wall us WHERE us.uid = '{$showU[id]}' ORDER BY `date` DESC"); This is what I have right now. And I need some more columns from users_wall, ...