mysql

How to efficiently find the closest locations nearby a given location.

I'm sorry for the vague question title... its going to take a bit of explaining... Basically I'm making a script where a load of business are loaded into a mySQL database with a latitude and longitude. Then I am supplying that script with a latitude an longitude (of the end user) and the script has to calculate the distance from the sup...

ranking in MySQL in a single sql statement

I have a simple table storing id and the score of the student. I would like to select the rank of a student id in a single sql statement. I have found several post here but they involve parameters or temp table which I don't want to mess with them as I'm using hibernate. Can someone introduce a single SQL statement which can do this j...

Problem with Identity generation when using nHibernate with MySql

Please, help! I new to nHibernate and I stuck on problem - I can't create new persisted object via NHibernate (2) In this code: foreach (var item in items) { if (item.price > 0) { if (_itemsForBuy.FirstOrDefault(i => item.itemid == i.itemId) == null) { var ifb = new ItemForBuy() { id = 0, item = item, count = 1...

Will this get Search Engines to index my content?

I have a classifieds website... The classifieds are displayed in a dynamic php page. For instance, if one searches for "bmw m3" in the form (which is in index.html) and submits, then a php page will appear showing results. The php page called results.php, connects to mysql databases and fetches the information, and puts them in a tabl...

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

Hell there when i try and connect to pull thing out of the database i get the following error: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/content/49/5548763/html/matt/download.php on line 17 None of the other answers on this site worked. here is the script: <?php $con = mysql_conn...

Converting ms access to mysql with relationships

I have tried some tools (such as mysql migration toolkit and bullzip's Access To MySQL utility.) that convert a ms access database to mysql which all successfully create the database, tables and insert the data. What they do not appear to do is recreate the relationships (constaints) from the original ms access database into mysql. Ar...

MySql, Sqlite, Wix; Opinions, Suggestions, Ideas

Hi, Currently I am working on a project, which uses a server base MySql to save some test results from equipments they make, and program works fine and at each test end it uses saved data to generate report with results. My client wants to use the same program in technicians laptops so they can visit various sites but there is no connect...

Loop through form input array

I have a dynamic output form where the text input fields have the same name. I need to loop through the text inputs and insert multiple rows into the database for each text field input. $sql="INSERT INTO orderitems (orderNum,productNum,quant) VALUES ('$num1','$_POST[pNum]','$_POST[quant]')"; <input type="text" name="pNum" ...

MySql Join tables

Hi Guys! I have two tables like this. Table 1 Fields: CId , Name Table 2 Fields: CId , food I want to get no. of food against each CId with the query "select * from table1" ...

Optimize this SQL query's GROUP BY on a big table.

I have this query: SELECT weekno, dt, SUM(CARRYOVER) AS CARRYOVER, daycode, COALESCE('N','N') AS FLAG, DATE_FORMAT(STR_TO_DATE(CONCAT(YEAR(dt), weekno, ' Sunday'), '%X%V %W') , '%c/%d/%Y' ) AS ENDOFTHEW...

mysql select from different table depending on master table

I have 3 tables and am trying to do something like the query below but that does not work: SELECT * FROM tableA a if a.typ=0 then tableA-0 b else tableA-1 b end if where a.id = b.id See what I am needing is if tableA typ is zero then pull from tableA-0 else pull from tableA-1. This can not be 2 queries. thanks ----Edit---- SELECT ...

How to concat_ws multiple fields and remove duplicate separators for empty slots

When you CONCAT_WS(' ',field1,field2,field3) in MySQL and if one of the fields is empty, not null, you get multiple separators. An example can be: John[space][space][space]Doe[space]III. How can I make sure there is only one separator. ...

Implementation of NORMSINV function in MySQL.

Hi all. I need to use the inverse normal cumulative distribution function (what in Excel is NORMSINV function) in MySQL, but there is no such function there. Maybe any of you has an implementation of it for MySQL? Many thanks for your time. ...

migrating two pieces of code, error mysql_fetch_array() expects parameter 1 to be resource

Hello, I have migrated some codes, all went fine till I encountered this code in the tutorial. Because I have a custome template, the html and php code is a little different from the original template, now I'm totally lost. This is the original code, which should be replaced with the one beneath this code: <table cellspacing="0" cellp...

Importing a MySQL schema to Xcode as a CoreData Data Model

I have an existing MySQL database, I would like to import the schema into Xcode and create a Core Data data model. Is there a way (tool, process) to import the CREATE statements so I don't have to build the models "by hand"? As an intermediary step I could convert to SQLite, I'm not worried about the relationships, foreign keys etc jus...

How to SELECT a column composed by some other columns value

I have a daycode column that stores values like 1,2...7 then in a different table I have cols like field1,field2...field7 I can join them on a key, but how do I select the specific fieldX column based on values passed? Table 1 has the following columns ------------- id prodno field1 field2 field3 field4 field5 field6 field7 Where eac...

Return 404 if non existant page # PHP

I have a dynamic review system in place that displays 30 reviews per page, and upon reaching 30 reviews it is paginated. So I have pages such as /reviews/city/Boston/ /reviews/city/Boston/Page/2/ /reviews/city/Boston/Page/3/ and so on and so forth Unfortunately, Google seems to be indexing pages through what seems l...

MySQL UPDATE statement times out

The following very simple snippet of SQL is failing: UPDATE smalltable,bigtable SET smalltable.ssn=bigtable.ssn WHERE smalltable.last = bigtable.last && smalltable.first = bigtable.first; bigtable has 16,000 records -- not really all that big for SQL. smalltable has about 300. For some reason this statement is timing out (> 30 secon...

PHP & MySQL - You have an error in your SQL syntax problem.

I get this error below and was wondering what is it? And what can I do to fix it? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND articles_comments.user_id IN()' at line 6 Here is my MySQL code. $u_id2 = array(); $dbc = mysqli_query($my...

MySQL Select: Get Main Record(s) by Multiple Attached Records?

Not sure how to ask this so it makes sense, but I'm trying to do a query like: SELECT * FROM PAGES WHERE an attached record exists in PAGE_FILTERS and that record has a FilterTypeID of 22 AND another attached record exists in PAGE_FILTERS for the same page ID and that record has a filter type id of 27. I have a structure like this: P...