Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. jeff5311

    Weighted Random Select

    I constructed a query which might return results faster, but it has all these nasty subqueries. Is there a better way to write this? SELECT * FROM ( SELECT *, ( SELECT SUM( weight ) FROM table t2 WHERE t2.id <= t1.id ) AS sum_weight FROM table t1 ) AS t3...
  2. jeff5311

    Weighted Random Select

    Thanks Tony!!! That SQL significantly dropped the load on the server... I'm not sure why (it still has the dreaded "ORDER BY RAND()" in there), but it's working great!!! thanks againg for all your help. jeff
  3. jeff5311

    Weighted Random Select

    Thanks Rudy and Tony! I'll try both methods, but I think any SQL statement with the "ORDER BY RAND()" clause in it will have poor performance... but I'm no guru, it's just what I've read. Thanks again for your help!!! Jeff
  4. jeff5311

    Weighted Random Select

    Tony, Yes you are correct!!! I want more probability of the higher-weighted records returned. Again, the above query works probability wise, it just gets slower and slower as the table grows. Does anyone know how to re-write this? Help!!! Thanks, Jeff
  5. jeff5311

    Weighted Random Select

    Thanks for your help!!! Unfortunately, MYSQL tells me this isn't valid syntax and won't run the query. Any other suggestions??? Help!!!
  6. jeff5311

    Weighted Random Select

    I'm trying to retrieve a "random" row from a table where the randomness is "weighted" by a factor, let's call it "weight" (original, huh?). the following (pseude-SQL) works but is EXTREMELY slow: SELECT * FROM table ORDER BY RAND() * ( 1 / weight) LIMIT 1; I've read that "ORDER BY RAND()"...
  7. jeff5311

    Another MySQL Join Question

    Oh no! I have version 4.0.15 of MySQL. Is there another way to write the query without a sub-select? Thanks!!! Jeff
  8. jeff5311

    Another MySQL Join Question

    Tony, Thanks for your help! That looks like it might work, but I can can't get MySQL to evaluate the sub-select. It gives me a syntax error #1064 (I'm using phpMyAdmin to run the query) as follows: MySQL said: #1064 - You have an error in your SQL syntax. Check the manual that...
  9. jeff5311

    Another MySQL Join Question

    Sorry for all the questions guys! I'm a SQL newb... I have 2 tables I'm trying to join: traits trait_num trait_name trait_value 1 color blue 2 color red 3 color green 4 size small 5 size medium 6 size...
  10. jeff5311

    MySQL JOIN Question

    Thanks for your help guys! r397 - that's exactly what I was looking for... it works perfectly. Thanks Again! Jeff
  11. jeff5311

    MySQL JOIN Question

    This query I'm trying to construct seems simple, but I can't get it to work. Can someone please help?!?!?! I have two tables... My "products_to_traits" table has the following data: product_num trait_num 1 1 1 12 1 23 1 30 2 1 2 30 2...
  12. jeff5311

    Can I Write this Query without a sub SELECT?

    ericbrunson, your SQL worked great! you are a lifesaver! thanks so much for your help. jeff
  13. jeff5311

    Can I Write this Query without a sub SELECT?

    thanks for your help! if the table is named "categories," do you mean: select a.category_value from categories as a join categories as b using ( product_id ) where b.category_value = 'engineering' if so, i'll try that and report back. thanks again!
  14. jeff5311

    Can I Write this Query without a sub SELECT?

    good question! sorry i wasn't clear to start. i want only values that all widgets with a red value have (i think!). another example from the data would be: if i selected "engineering," i would want to return "black," "red," "square," and "round," since widget1 and widget2 have all of those...
  15. jeff5311

    Can I Write this Query without a sub SELECT?

    i'm trying to construct what i believe would be a fairly simple query against 1 table with just 3 columns. however, with my limited sql knowledge, it feels like i'm going in circles. can any mysql gurus please help? my table is called "categories" and has the following fields and example data...
  16. jeff5311

    Multiple Instances of a Report

    Steve, Yep! That certainly makes sense... only I don't have the destination printers (they can be local printers, network printers, &quot;non-standard&quot; faxing software, etc...), and as you can imagine, each user's machine can have different printers. So it's easier in my case to just pull...
  17. jeff5311

    Multiple Instances of a Report

    Steve, Your right, the serial print probably would work, especially if I were sending the reports directly to the printer. I guess I was trying to open each report in &quot;Preview Mode&quot; in parallel so they each could be faxed or sent to a different printer individually (specify the...
  18. jeff5311

    Multiple Instances of a Report

    Hey guys! Thanks for your input... I was able to figure it out. Here's what I did: 1) Declare a global variable (in the module header, outside of the subroutine) like this: 'Assume we'll never need more than 25 instances of the 'same report open at once Dim rpt(1 To 25) As Report 2) set a...
  19. jeff5311

    Multiple Instances of a Report

    Does anyone know how to open multiple instances of the same report? I have a report named: rptPOs I need open multiple instances of the report at one time (so the user will know to print ALL instances of the report). I'm trying to open each report each report passing different filter criteria...
  20. jeff5311

    Does anyone know how to create this QUERY?

    Thanks again Terry! The crosstab solution makes sense, but I like your self-join solution better. In case anyone is wondering, here's the self-join with multiple option values: SELECT a.[Index], a.[Option Value], b.[Option Value], c.[Option Value], d.[Option Value]...

Part and Inventory Search

Back
Top