mysql

Turning a text string of week numbers into array of values with jquery

Hi, I've been battling with this for a while: I've got a mysql database of events happening on various weeks. For each event there is a field with the week numbers that it is occurring as a text string. e.g. W01-W04, W06, W08, W10 How can i convert that that to an array of values with jquery? e.g. W01, W02, W03, W04 ect.. And then ...

Retrieving like counts on entries from SQL.

Hey all, I've been adding a like feature to an entries database... here's the structure of the DBs: **Users** user_id user_name etc. **Entries** entry_id entry_content etc. **Likes** user_id entry_id (It's a little more complicated than that, there are groups/categories, but that should explain it fine...) Here's the SQL query I'm ...

Effecient mysql query multiple tables

Hi all, I have a database with 2000 games. Each game consists of 15 numbers from 1-90. Each time I submit a number in the database, I want my results to update, so I’m always seeing the games that are nearest completion. (Only viewing 50 games at a time). My database structure looks like this: Table: game id name Table: game_numb...

SQL - Retrieve values in a single query with multiple where clauses

I have a table with the following data: UserName | LastLogin ------------------------------- User1 | 2010-10-25 10:05:47 User2 | 2010-10-23 11:10:27 User3 | 2010-10-12 05:39:34 User4 | 2010-10-20 12:22:11 User5 | 2010-09-17 08:41:05 I want to be able to run a query to get the number of people who have logged in in the ...

Special characters behaviour in Restful web services + Eclipselink + Java

Hello, I have written few Restful web services using Eclipselink for object relation mapping. Now i am calling these services from client side through GET method. Here while passing some special characters as a part of data, i am facing following problems -- 1) + character is storing as space character in database(MySql). 2) How to pas...

MySQL if/else for tables

Is there a way to if else tables in mysql? Example: select * from tableA A, if(tableA.find=1,TableBA B,TableBB B) where A.id = B.aid Real Example: tables are: location_order, order_contract, order_gm, order_gm_hh: select * from location order lo, order_contract oc, if(lo.hh=0,order_gm,order_gm_hh) as og where lo.orderid = oc.o...

Multiple MySQL Queries and fatching MIN price from a table

TABLE PRODUCTS_CATEGORIES product_id category_id link_type position 2 22 M 0 3 22 M 0 4 22 M 0 5 22 M 0 6 1 M 0 7 1 M ...

php do something for every record in the database

Hey everyone I have two tables in the database(videos and viewData) . Im trying to build a script that runs for each record in the "videos" table and does something using the "videoID" field for that specific entry in the "videos" table. The does something part would be dumping some data into the viewData table. Would I need to store ...

how do i use the mysql general log?

I notice a very weird problem in my code. I am inserting a value of 128 but in my database it says 127. I'd like to look at the mysql general/query logs however i dont ever see any log files produce no matter what i do. I tried -l , -l with an absolute path and --general_log_file. No luck. I also used mysqladmin flush-logs. Still nothin...

Issues with stored JSON encoded POSTs in MySQL

I have a situation where after several years of use we are suddenly have some JSON-encoded values that are giving our Perl script fits due to backslashes. The issues are with accented characters like í and é. An example is Matí encoded as Mat\ud873. It is unclear what may have changed in the environment. PHP, Perl, and MySQL are involv...

Export a MySQL table via JOIN?

Hey guys..... I was wondering if rather than creating another table to store the results of the MySQL JOIN query is it possible to just export a queries result.... like to a CSV? The query for example would be something like this.. SELECT us.id, CONCAT_WS(' - ',cats_sic_us.sic,cats_sic_us.category) AS sic_cat FROM us I...

How do I set a MySQL field to be the dynamically generated value of another field?

I'm mucking around with drupal, and it has two fields called nid and vid on its node table. Every record I look at seems to have the same value for both nid and vid. I'm hacking around and inserting nodes the non-drupal way, and I want to make sure vid is set to whatever value nid has. For sake of explanation, here's something that I'd...

mysql_query in a while loop

I'm trying to execute I have an html form in a page of this sort : Name: <input type="text" id="namebox" value="" name="fields[]" /> <br /> Position: <input type="text" id="positionbox" value="" name="fields[]" /> <br /> <input type="hidden" name="createcard"> <input type="submit" value="Create"> .. and 3 other fields. I'm passi...

mysql simple problem with foreign keys

I have two tables: Table Author: ID (INTEGER), author_name (VARCHAR), first_name (VARCHAR), last_name (VARCHAR), preferred_name (VARCHAR). Table CoAuthored: ID (INTEGER) author1ID (INTEGER), author2ID (INTEGER), paper_ID (INTEGER) (ID of the co-authored paper referenced by this link) I want to add foreign key constraints such that aut...

mysql backup/restore (with respect to utf as well) from console

Hi, I was wondering was is the recomended procedure to do an sql backup and restore (respecting utf data integrity) from the console. The reason I am asking is because I am currently using a PHP script to do it, but I have problems during the restore with values that should be null but are restored as 0 and they break my functionality....

How to create a sitemap using PHP & MySQL.

I was wondering how can I create a sitemap using PHP & MySQL and is there any sitemap design examples you know of? ...

I get dual results from mysql query when using international charachters, i.e Å/Ä=A & Ö=O,

For example if I search for the name Åsa i only want to get the name Åsa and not Asa, same with Björn instead of Bjorn $query="select * from users where username like 'Björn'"; $result=mysql_query($query); $num=mysql_num_rows($result); echo"$num"; $i=0; while($i<$num){ $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$...

Are multiple sql querys a significant performance hit?

I am using MySql (and PHP). It's best if I give an example: I am making a query, say SELECT * FROM a_table WHERE type='visible' then returning the count. Then later I query again but WHERE type='hidden', etc. I may query again to get the full contents. All queries are unique, but are from the same table. I also query multiple other tabl...

Mysql default timezone

My server is in US, and I'm in istanbul. Problem is I want to ask mysql about current time. Is there a function to adjust it's time accourding to mine? select * from xyz where dateTimeField<now(); dateTimeField will available after 10 hours that it shoud be! ...

I write a MySQL table into an output file (working on Unix) but I can not enter the file directory (permission denied)

When I output a whole table into an output file named 'Arshan.txt' this command works well but I can not access the output file created. When I access /usr/local/mysql/data it says permission denied. Any help will be appreciated. Thanks in advance. ...