Jump to content

elgoog

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

elgoog's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a table of items, a table of attributes and a table of attribute links (attriblinks) When a list of 15 attributes are selected, I want to return the list of items that have all of those attributes This list is then used to select all items and all attributes for the list of ItemID's
  2. I have a problem trying to make a query with lots of joins which is slowing down. attriblink ItemID | AttribID 1 | 1 1 | 2 1 | 3 2 | 1 2 | 2 3 | 3 With the table above i am using the following query SELECT distinct(A0.ItemID) FROM attriblink A0 JOIN attriblink A1 ON A0.ItemID = A1.ItemID AND A1.AttribID = '2' JOIN attriblink A2 ON A0.ItemID = A2.ItemID AND A2.AttribID = '3' This only brings back record 1, which is the result i need and works really fast up till about 8 joins, then on the 9th slows down a to >10 seconds Example SELECT distinct(A0.ItemID) FROM attriblink A0 JOIN attriblink A1 ON A0.ItemID = A1.ItemID AND A1.AttribID = '21' JOIN attriblink A2 ON A0.ItemID = A2.ItemID AND A2.AttribID = '49' JOIN attriblink A3 ON A0.ItemID = A3.ItemID AND A3.AttribID = '14' JOIN attriblink A4 ON A0.ItemID = A4.ItemID AND A4.AttribID = '90' JOIN attriblink A5 ON A0.ItemID = A5.ItemID AND A5.AttribID = '59' JOIN attriblink A6 ON A0.ItemID = A6.ItemID AND A6.AttribID = '55' JOIN attriblink A7 ON A0.ItemID = A7.ItemID AND A7.AttribID = '1' JOIN attriblink A8 ON A0.ItemID = A8.ItemID AND A8.AttribID = '66' JOIN attriblink A9 ON A0.ItemID = A9.ItemID AND A9.AttribID = '23' In the actual database there are 100,000 rows and there may be 25 attributes selected is there a faster and better way to run this query?
  3. Cheers Keith... Have it all sorted and working using this method.
  4. I am hoping this makes sense once i write it down... here goes... table1 --------------- id name 1 one 2 two 3 three table2 ------------ id type 1 1 1 2 2 1 3 2 Bringing back distinct records with a type of 1 SELECT Distinct(id), name, type FROM table1 LEFT JOIN table2 ON table2.id = table1.id WHERE table2.type = 1 brings back...... id name type 1 one 1 2 two 1 This is ok..However.... i now want to bring back the distinct id's that have types of both 1 and 2 SELECT Distinct(id) FROM table1 LEFT JOIN table2 ON table2.id = table1.id WHERE table2.type = 1 AND table2.type = 2 This brings back 0 records using OR brings back records with either SELECT Distinct(id) FROM table1 LEFT JOIN table2 ON table2.id = table1.id WHERE table2.type = 1 OR table2.type = 2 id name 1 one 2 two 3 three i am looking to only return the result id name 1 one as this is the only one who has a joined record with both 1 and 2 Thanks in Advance.
  5. Do you need to put a character limit on it, or just limit to a certain width?
  6. I have been trying to find the simplest examples to parse JSON, and can't get any to work http://www.json.org/json2.js <html> <head> <title>Parsing Message using JSON in JavaScript</title> <script language="javascript" src="json2.js"></script> <script language="javascript" > var students = { "Maths" : [ { "Name" : "Amit", // First element "Marks" : 67, "age" : 23 }, { "Name" : "Sandeep", // Second element "Marks" : 65, "age" : 21 } ] } // Printing Maths array values in the alert message var i=0 var arrayObject = new Array(); for(i=0;i<students.Maths.length;i++) { arrayObject.push(students.Maths[i].Name); arrayObject.push(students.Maths[i].Marks); arrayObject.push(students.Maths[i].age); } alert("Parsing JSON Message Example "); alert(students.Maths[i].Name); alert(arrayObject.toJSONString().parseJSON()); alert("Parsing JSON Message Example "); </script> </head> <body> Parsing Message using JSON in JavaScript </body> </html> The example above is not working for me, only the first alert pop's up. I have also tried var people = { "programmers": [ { "firstName": "Brett", "lastName":"McLaughlin", "email": "brett@newInstance.com" }, { "firstName": "Jason", "lastName":"Hunter", "email": "jason@servlets.com" }, { "firstName": "Elliotte", "lastName":"Harold", "email": "elharo@macfaq.com" } ], "authors": [ { "firstName": "Isaac", "lastName": "Asimov", "genre": "science fiction" }, { "firstName": "Tad", "lastName": "Williams", "genre": "fantasy" }, { "firstName": "Frank", "lastName": "Peretti", "genre": "christian fiction" } ], "musicians": [ { "firstName": "Eric", "lastName": "Clapton", "instrument": "guitar" }, { "firstName": "Sergei", "lastName": "Rachmaninoff", "instrument": "piano" } ] } alert(people.programmers[0].lastName); Can someone please provide me with a simple example of a JSON structured variable, with a simple alert message that accesses something in between? Not sure what i am doing wrong
  7. After lots of experimenting, i finally figured this out.... Topic Solved.
  8. This might be of use to start with, there is a live demo and source code available, http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html
  9. Thanks for looking at this FanFavorite What i am basically trying to acheive. Is to have a table displaying all rows from 'table 1' Each row in table 1 may have multiple rows associated with it in 'table 2' When i run the function, by clicking the relevant expand button, on that row, it should call the information from the database using an external php file, and place the information in rows below the right row that was clicked on. The function below var tblBody = document.getElementById('table1').tBodies[0]; var newRow = tblBody.insertRow(-1); newRow.innerHTML = req.responseText; This will place the information correctly as it pulls from external file as <td></td><td></td> However it places it at the bottom of the table and not below the correct row. I have tried passing the row number to the function and using the index for the right row number, however this does not take into account additional rows that are inserted.
  10. I am struggling in getting some data from AJAX to appear in the right location <table> <tr> <td><a onClick="getData(1)">get data</a></td><td>Data</td><td>Data</td> </tr> <div id="1"></div> <tr> <td><a onClick="getData(2)">get data</a></td><td>Data</td><td>Data</td> </tr> <div id="2"></div> </table> Ajax - if getData(1) is run. It returns <tr><td>My Data</td><td>My Data</td><td>My Data</td></tr> and uses the following to place this within the <div id="1"></div> tags. document.getElementById(1).innerHTML=req.responseText; Except the data does not appear as a new row, it appears above the table. If i paste <div id="1"><tr><td>My Data</td><td>My Data</td><td>My Data</td></tr></div> into the right place, the table shows up fine, but not when brought in using AJAX. If anyone can shed some light on this, that would be great.
  11. Thanks - It still did not work doing this. Turned out i forgot to put what metric i wanted to filter before the expression.... It does work with normal URL encode and i think it is time for a coffee!!. Thanks for the help.
  12. In the filtering section you have to pass through !=, >, < etc in the encoded formats http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#filtering However in PHP <? echo urlencode("!="); ?> This generates %21%3D as the endoded format, however in the google docs it needs to be !%3D Are there any functions available to encode an URL in the format google requires? Thanks in Advance
  13. @ken2k7. The one column for the count rather than the two makes sense. Thanks
  14. Thanks for the reply I was simplyfying some of the tables, the item table has a lot more columns The thought process on not having individual rows in one table, is so i could have a count in the field. And to query and get that number would hopefully be less resourceful that counting the rows. As the userid - vote check would only need to be done if someone tries to vote. Where as with 10 items diesplaying on a page. Having to loop through and do a count to display totals i was thinking may be intensive on the database server
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.