mysql

How to open problematic data dump and convert it to mysql (or some other practical format)?

I'm trying to work with pretty interesting data set. Unfortunately, I have problems with opening it and converting it into any useful format. It's collection of archived txt files. When i decompress them and try to open txt file i get 'it's binary file, saving it may result in corrupt file' and it's unreadable - there are just 'weird cha...

Need REGEXP Matching in MySQL

I want to match a String which looks like this: [lang_de]Hallo![/lang_de][lang_en]Hello![/lang_en]HeyHo[lang_es]Hola![/lang_es] I want the matching to return true if there is text which is not enclosed by lang_tags (in this example: HeyHo). It could also be positioned at the beginning or end of the string. Whitespace should NOT match...

Why does MySql allow "group by" queries WITHOUT aggregate functions?

Surprise -- this is a perfectly valid query in MySql: select X, Y from someTable group by X If you tried this query in Oracle or SQL Server, you’d get the natural error message: Column 'Y' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. So how does MySql determine w...

How can I have a column in a MySQL database be a function of other columns?

I'm working with a database that keeps track of where a reader is in a book. I do this by having a page count column and a current page column. Is there a way to add a 'progress' column that would be equal to (currentpage/pagecount)? ...

How do I use group by showing the newest row of data

Can someone please tell me how to use the group by clause, grouping by one of the keys in the table but yet having the newest timestamp at the top? I have multiple rows of data but I only want to show the newest row ...

Insert user IP Address into MYSQL Trigger

I'm creating a MYSQL Trigger. I'd like the trigger to record the ip address of the user who initiated the database change. Is this possible? And if so, how can MySQL get the user's IP Addy? ...

what is this sql statement doing? (mysql)

SET @row := 0; SELECT * FROM ( SELECT @row := @row+1 AS rank, account_id, keyword, bid_amount ,timestamp FROM bids WHERE keyword='programmers' ORDER BY bid_amount DESC, timestamp ASC ) AS derived_table; i saw this somewhere and i was wondering what the set does along with the @ sign and the := thanks ...

MySQL 1443: what does it mean?

I'm trying to do an update, in MySQL 5.0, of the form: update mytable.myfield t set f = 'blah' where t.id in (select v.id from myview v where ...); MySQL tells me: ErrorNr. 1443 The definition of table 'v' prevents operation UPDATE on table 't'. The MySQL docs list this error, but (as usual) don't say what it means. Can anyone she...

PHP/MySQL / Use String to SELECT from Database

Hi all, I have a string: $string = "12,15,22"; Each of these values represents a usrID and I'd like to use these to select the rows associated with the $string. Something like this: SELECT usrFirst, usrLast FROM tblusers WHERE usrID = 12 OR 15 OR 22. Now, the $string changes all the time, and sometimes can be a different number...

PHP str_replace

I'm currently using str_replace to remove a usrID and the 'comma' immediately after it: For example: $usrID = 23; $string = "22,23,24,25"; $receivers = str_replace($usrID.",", '', $string); //Would output: "22,24,25" However, I've noticed that if: $usrID = 25; //or the Last Number in the $string It does not work, because there is...

can Mysql or sqlite Blob data type store varchar data in it?

Hi All, Can one anyone provide any information on whether can we store normal text data(varchar) in mysql or sqlite Blob data type ...

mysql insert syntax for blob data through Stored procedure

Hi All, I want to insert an img file in mysql database, can anyone provide normal insert statement for inserting blob into mysql database. How i can do it as if i specify the path it stores the path only not the img ...

MySql conditional short descriptions

Please help me fetching google like url descriptions in just one SQL query. see example If description is greater than a fixed limit of characters say 100 characters then append '...' otherwise show the complete description. My current SQL query is this: SELECT post_id, CONCAT( LEFT( post_text, 50 ) , '...' ) AS text FROM posts Pl...

Update Exist Data Using DataRow C#

hi. I need to update my exist data in mysql database. I write like this code; String _id = lbID.Text; dsrm_usersTableAdapters.rm_usersTableAdapter _t = new dsrm_usersTableAdapters.rm_usersTableAdapter(); dsrm_users _mds = new dsrm_users(); _mds.EnforceConstraints = false; dsrm_users.rm_usersData...

Store news from mysql in php array!

Hello! I have following script: $cbid = 0; $arrayid = 0; while ($FINDNEWSresult = mysql_fetch_array($FINDNEWSquery)) { echo "<tr>"; // Prvi stolpec - označevanje (checkbox) echo "<td class=\"middlerow checkbox\"><input id=\"" . $FINDNEWSresult['NEWSid'] . "\" type=\"checkbox\" /></td>"; echo "<td class=\"middlerow\"><a class=...

Is Markdown (with strip_tags) sufficient to stop XSS attacks?

I'm working on a web application that allows users to type short descriptions of items in a catalog. I'm allowing Markdown in my textareas so users can do some HTML formatting. My text sanitization function strips all tags from any inputted text before inserting it in the database: public function sanitizeText($string, $allowedTags = "...

mysql/php: keeping an extra record while paging

I have a list of records that I want to page through using LIMIT however the first record that is returned without LIMIT is also the root identifier for the rest of the records and I need to keep it for every page. Is this possible? (I would just prefer not to run a extra sql statement) id | index | title 1 | 0 | index of t...

Database-Independent to_char Function in SQLAlchemy

I am using SQLAlchemy to make database-independent querys. I am facing one issue with to_char function. Consider the simple query like: select to_char(id,'999') from xyz It's working on Postgres but MySQL doesn't support it. How can I make this query database-independent using SQLAlchemy? ...

Generate number id from text/url for fast "SELECT"

I have the following problem: I have a feed capturer that captures news from different sources every half an hour. I only insert entries that don't have their URLs already in the database (URL is used to see if the record is already in database). Even with that, I get some repeated entries, because some sites report the same news (tha...

mysql function to provide equivalent to Oracle NVL

I have a strange situation. I have to use NVL(columna, columnb) in Oracle and MySQL. I can't change the SQL as it is in a package I can't edit but it is the only thing that doesn't work in the application I have between MySQL and Oracle. How would I write NVL() in MySQL. I've looked here (http://dev.mysql.com/doc/refman/5.0/en/create-fu...