Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Query To Search And Retrieve File For Download


I am new to web development and have this challenge. I want to design a dynamic website for a college community using PHP and MYSQL. The objective of the site is to hold the annual report of all the departments such that visitors can select the desired department and the year of the report. The years could stretch back to as long as the college existed but I want to limit the backdate to 10 years for now. The visitor should be able to select a department and desired year, view the report online and also be able to download the same report stored in a directory in ms word or PDF format. What should the table structure look like? Also the PHP and SQL script to search for the stored files and make them available for download.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Where To Download The Latest Mysql Manual Download
i searched google, unable to find.

Download Of Mysql.sock File Unable To Connect To Mysql Server
Where can i get the download mysql.sock file?

I am unable to connect to local server because i dont have this file?

Retrieve Everything AND Count Rows In One Query
set rsminmax = con.execute("SELECT * FROM `minirules_minmax` where RuleId = '" & contractId & "'")
set rsminmax2 = con.execute("SELECT COUNT(*) FROM `minirules_minmax` where RuleId = '" & contractId & "'")


Is there any way to do this in one SQL query?

Query To Retrieve This Week's Birthdays
I have a Members table in my database in which I collect the date of birth for each member. I have been trying to write a MySQL query to retrieve the birthday's for this week from the Members.DateOfBirth field, which is of type datetime.

I have been able to successfully retrieve Member's birthdays for this month using the following query, but can't figure out how to take the query to the "this week" level.

Does anyone know how I could do this?

Here is the query I am using now to retrieve birthdays for this month:

Retrieve Data From 2 Tables In 1 Query
I've got 2 tables content & sections I need to:

SELECT id, title, section_id , status FROM content

and now I'd like to get title from sections WHERE id = section_id from the first part of the query.

I've tried with unions but doesn't seem to like it..

Search Not Only By Description, But With File Name
i have a search engine tat is able to search in mysql database for by the file description , but i want to add an additional feature tat is able to search for the file_name as well..

i tried adding the file_name field name into the condition query below with the OR CLAUSE, but alot of irrelvent results would appear. the same file will be listed out more than once.

codes:

select file_group_url.g_url,
file_record.file_desc,
file_record.file_name,
date_format(file_record.file_date_create,'%w-%m-%y'),
file_group_url.g_groupfrom file_record,
file_group_url
where file_record.G_id = file_group_url.G_id
and file_record.File_desc like'%'(user_id session value)
or file_record.File_name like'%'(user_id session value)

Query To Retrieve The Last "X" Rows
I need create a query to retrieve the last 10 rows of my table.....

Date Search Query Help
I'm trying to filter my search results by date. The field name I'm running this for is final_date and is a DATE field.

I want my results to show records that have sales_reps.final_date within the past 30 days.

Query:

SELECT
sales_reps.sr_id,
sales_reps.name,
sales_reps.job_number,
sales_reps.status,
sales_reps.stage,
UNIX_TIMESTAMP(sales_reps.final_date) as final_date,
UNIX_TIMESTAMP(sales_reps.date_to_shop) as date_to_shop,
shop_orders.community,
users.user_id,
u.fname,
u.lname,
users.builder,
users.division,
ei.shop_result,
ei.good_tape,
sa.shopper_id,
shop_orders.order_id,
UNIX_TIMESTAMP(shop_orders.date) as order_date,
pi.fname as pfname,
pi.lname as plname ,
ei.exit_id
FROM sales_reps
LEFT JOIN shop_orders ON sales_reps.order_id=shop_orders.order_id
LEFT JOIN users ON users.user_id=shop_orders.builder_id
LEFT JOIN report_types ON report_types.type_id=sales_reps.report_type
LEFT JOIN shop_assignments as sa ON sa.sr_id=sales_reps.sr_id
LEFT JOIN exit_interviews as ei ON ei.shop_id=sa.shop_id
LEFT JOIN users as u ON u.user_id=sa.shopper_id
LEFT JOIN users as pi ON pi.user_id=sa.pi_id
WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <=UNIX_TIMESTAMP(sales_reps.final_date)
AND (sales_reps.status = 'Completed' OR sales_reps.status = 'Rejected')
ORDER BY users.builder, users.division, community ASC, final_date ASC
Is this:

WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <=UNIX_TIMESTAMP(sales_reps.final_date)
incorrect?

I'm getting dates such as 2007-03-22 and 2007-03-19 in my result set and they shouldn't be there.

Could I get some pointers?

Correct Search Query
Can anyone help me out with this please. I am looking at searching among comma delimited id's stored inside "IDs", trying to figure out what the correct SQL query for that would be. I need to extract the ID where IDs contains the value 7. I know I can't use something like "WHERE IDs LIKE '%7%'" because the result would be inaccurate. So how do I go about it, please? Any directions would be appreciated, thanks!

+------+-----------+
| ID | IDs |
+------+-----------+
| 1 | 3,17,20 |
+------+-----------+
| 2 | 1,7,9,12 |
+------+-----------+

Search Database Query
I am looking for a query that will search all of my database without having to use all the individual table names and fields as there are 6 tables and over 30 fields in the database is there any special expression for this the search criteria would only be one word.

Mysql Search Query
i would like to write a query to seach for the related information to display.

let say the user key in the word "sql", and in one of my keyword field i have data such as "mysql, database, java" and i want to call this row out, how can i do this?

Search Query By Date
I'm trying to adjust an older search query to perform a search by date where the date column is an INT field (unix date stamp).

SELECT * FROM incidents WHERE date < DATE_ADD (CURDATE(), INTERVAL $searchDate DAY);

Where date, formally a DATE field, is now an INT(11) field. $searchDate is an int, indicating how many days back to search. 1 (day), 5 (days), etc.I'm assuming mysql's DATE_ADD function is specific to the DATE field. How can I achieve the same result, but with an INT field?

Query Search Direction
It's possible to tell mysql to start searching rows from highers indexes to lowers?

MySQL Search Query
I have two tables as follows:

table 'question' with fields 'patient_id', 'answer_id' and 'terms', and

table 'answer' with fields 'answer_id' and 'answer_path'.

I need to search question.terms for a keyword match and then join that match to the corresponding foreign key (answer_id) in table answer to return 'answer_path'.

Best Download
I want to download mySQL on a Windows XP box running IIS. I went the mysql.com website and selected download. There are many options. I assume it is one of the top options, listed below.

Please provide any advice on the best version to download. If neither of these are the best, please provide me with a better source. Code:

Download
Experiencing problems downloading the MySql .dmg file? The file downloads and we cannot open it, we are 'mac OSX' based is this the reason? Can this download be made easier?

[PHP, MySQL, FLASH] - Search Query
just a quick question what would be the best way to search a database, how should i query it? i have this so far:

<?
$name=$_GET['name'];
$company=$_GET['company'];
$address=$_GET['address'];
$phone=$_GET['phone'];
$email=$_GET['email'];
$web=$_GET['web'];

mysql_pconnect("host","random","random") or die ("didn't connect to mysql");
mysql_select_db("database") or die ("no database");

$query = "SELECT * FROM table_name WHERE Name, Company = '$name' AND '$company'";
$result = mysql_query( $query ) or die ("didn't query");

$num = mysql_num_rows( $result );
//echo ($num);
if ($num == 1){
while ($line=mysql_fetch_array($result)) {
$profile = "name_show=" . $line['Name'];
$profile = "company_show=" . $line['Company'];
//$profile = "address_show=" . $line['Address'];
//$profile = "phone_show=" . $line['Phone'];
//$profile = "email_show=" . $line['Email'];
//$profile = "web_show=" . $line['Web'];

}
print $profile;
} else {
print "error=Sorry, but I can't show results";
}
?>

it works but not very dynamically, when both companys are commented out in the while and query statements.

What i hope to have is a search where users can type in 1 letter and it will give them a result with all records having that letter in them and just by filling in one item in flash instead of all of them in order to begin the search.

Incorporate OR Operator In Search Query
I have 2 tables, one with restaurants and one with US centroids, latitudes longitudes, zipcodes for varius central cities in the us.

I have a query that I got working, that uses these 2 tables, it selects all restaurant data from table Restaurants city/state/zip... where the restaurant zipcodes are within the dynamic radius specified of the zipcode(centroid) specified.

This works fine, It also returns the distance as well.

I would also like to select restaurants records regardless if the the distance between zipcodes only IF the Restaurant City matched the CIty I pass to the query. I tried adding an OR operator but my query hung.

Here is my query:

Query A Thesaurus For Search Terms?
I was wondering what the best way is to expand on user-inputted search terms.

For instance, when conducting a search, I would like to ALSO query all synonyms and related words to the inputted search terms.

The database my script searches is very large, so inputting my own related words and synonyms alongside every searched value in the database would be a real pain in the neck if I had to go that route.

Is there some sort of downloadable database of all words and their relations I could use?

Query Search In Different Table Columns
I'm trying to set up an sql-query to find a value in the table, which can exist in different columns......

Tire Size Search Query
I have a table of tire sizes... example: 245/40 YR18, 245/40 W18
I need to search through that table, and pick out sizes based on a search that would like like this: P245/40ZR18
I want to find tires based on the 'P245/40' and '18'... any combination of letters between the two are fine....
seems like a regular expression seach?

Query To Search Multiple Fields
I have a table with over 50 columns that contain yes/no values. I want to know if there is a way to write a query to get all fields that have a value of "no".

MySQL Download
When downloading the MYSQL files, how do I know which I need? Essentials x86, or Windows x86, or Windows x64, etc.?

MySQL5.0 To Download
Is MySQL5.0 free of charge or should I pay for it?

There are two categories of windows, ie, Windows and Windows x64 at http://dev.mysql.com/downloads/mysql/5.0.html.

What is diffent between Windows and Windows x64?

Download And Install OSX
I have downloaded the mysql-standard-5.0.24a-osx10.4 .tar archive from the MACOSX section of the download page and expanded the archive using Stuffit Expander 10.0.2. From what I understand I am supposed to end up with .dmg disc image file from which to install Mysql 5. However the archive expands into a number of folders with no .dmg file.

Table Download With PHP
I need to set a "Download" link in one of my pages so users can download a table's information on Excel CSV.

Can anyone please explain to me how this is done with PHP or where I can find information?

How To Download My Databases??
Have just recently setup my first site using MySql..I am transferring our hosting service, and need to download my databases to my hard-drive, then re-upload to the new host. How the heck do I do this? I already downloaded my public_html directory, but (stupid question), I don't think my databases/tables are located there. So, how do I find them, download them, and then re-upload them to my new host?

MySQL 4.0.27 (Win) Available For Download?
I've been looking around for the 4.0.27 version for windows (perhaps it's only for Linux?).

My internet provider uses 4.0.27 and I need to download and process my data on a local computer every once in a while, but I get some character issues on import/export (Ansi/Utf-8 converions).

I know I could try fix this via settings, but I also get mismatching SQL when downloading db structure, so I guess that the simplest and safest would be to use an exact matching version when manipulating the data.

What Version Do I Download?
i'm brand new to databases and want to download mySQL to practice with, i.e. some of my coldFusion tutorials require a database to complete. also, we use mySQL5.0 at work and i thought i should get a little familiar -- get my hands dirty. i know i have access to one with my hosting company for my site but would it behoove me to download a copy locally? what would be the advantages?

then, what version do i download? i have a dell desktop pc with windows xp. should i download the windows version instead of the linux?

Where Can I Download Mysql-max-5.0.45.tar.gz?
Where can I download mysql-max-5.0.45.tar.gz?

I only see downloads for mysql-5.0.45.tar.gz

Download Version 4.1.23
I've just downloaded the latest version for Windows 98/ME from the v4.1 download page..
That was version 4.1.22, but when looking at the changes in new versions, it says that v4.1.23 has been released and has many bugfixes in it.. so why isn't that version available as the latest download? ..instead of having to install 4.1.22 then having to do updates?

Now I know v5.0 and upwards is recommended, but they require w2000 or XP and up, which I don't have and can't afford right now. So leaving that aside, anyone know the reason for the latest release of 4.1.x not being on the appropriate page?

Mysqldump Download
I tried typing in mysqldump in  the client but it doesnt know what this is. Do I need to install something?

I was looking for a download link on the mysql site for the mysqldump program but cant find it. I do see mysql snap at other websites but want to get it from the official site if indeed it is a separte install.

MySQL Download
i m using windows xp family edition.I need to use MySQL with JSP.Which version of MySQL I should download.Please guide me.There is a list of its versions for windows platform.

Download MySQL
dose any1 know where 2 download mySQL?

SQL Query Problems (for Use With A Sort Of Live Search)
I created some code that loaded information from an XML file, but many thanks to jimfraser on here I'm working on a solution that'll drag it directly from the database.

Problem is, it's not displaying anything at all, so I assume there's a problem with the SQL query or the way it's being presented on the page.
PHP
<?php
 
$network = new COM("WScript.Network");
include_once('../../../functions/datalib.php');
 
$db = new oracleClass();
$conn = $db->connect();
 
//get the q parameter from URL
$q=$_GET["q"];
 
//lookup all links from the xml file if length of q>0
if (strlen($q) > 0)
{
    $hint="";
 
    // connect to the database
    $sqlstatement = 'select * from TEST."WFO_REPORTS_ALLEMPS" order by "Surname", "Forenames"'
    $sqlListings = OCI_Parse($conn, $sqlstatement);
       
    OCI_Execute($sqlListings);
    while(OCI_Fetch($sqlListings)) {
   
        $name = oci_result($sqlListings, "Forenames") . ($sqlListings, "Surname")
 
        //find a link matching the search text
        if (strchr($name,$q))
        {
            if ($hint != "") {
                $hint .= "<br />";
            }
 
            $hint .= "<a href='#' onclick='employee_form.Line_Manager_Staff_No.value="
            . oci_result($sqlListings, "Gc_Staff_Number")
            . ";checknumber('Line_Manager_Staff_No','displayusername');'>"
            . oci_result($sqlListings, "Surname") . ", " . oci_result($sqlListings, "Forenames")
            . "</a>";
        }
    }
}
 
// Set output to "no suggestion" if no hint were found
if ($hint == "")
 {
 $response="No user found.";
 }
else
 {
 $response=$hint;
 }
 
//output the response
echo $response;
?>

On a side note, is there a way I can change it so that the search will present any users based on their first name, as well as the surname?


Optimizing Search Query For Millions Of Rows
I have mysql 4.1 and Im having a difficult time optimizing this query.

select domain, length(domain) as len
from domains
where
length(domain) <= &#3916;' and
not (domain regexp '[[:digit:]]') and
domain not like '%-%' and
price > &#390;' and price < &#3916;' and
end > &#55614;&#57159;-12-01'
order by end ASC, len ASC
The following query outputs:


| id | select_type | table | type | possible_keys | key | key_len | ref | rows | extra |
-------------------------------------------------------------------------------------------------------------------------------------
| 1 | SIMPLE | domains | ALL | end | NULL | NULL | NULL | 2600000 | Extra where; Using filesort |
My indexes are:
ID - PRIMARY, Unique
domain - Unique
end

Is there anyway this query could be optimized anymore? With only 2.6 million rows its taking a 5 or 6 seconds. It looks like its not finding the right keys.

Mysql Query Search And Find In String
I have following values in a field of mysql table. These values are stored as string [varchar] in the field.

Values : 3,4,10,21,20,8,100,2,6

How can I check through MYSQL query that 100 or 21 or 4 exists in the string?



No MyOLEDB Driver Download Available
The download on your website for the MyOLEDB Driver is not working it says : "That file does not exist on our download mirrors." So how would I go about obtaining the driver?

Download MySQL Server 5.0.1 Win?
Does anyone know where i can download a copy of the installer of MySQL server 5.0.1 for Windows?

Which Version To Download For Red Hat 9 Linux
Which Version to Download for Red Hat 9 Linux?

Download.php Setup With Mysql
I am trying to make a download.php which would let users to download files after 5 seconds.

The only problem is that my /download directory has many sub directory.

For example if someone wants to download FireFox, then firefox.exe is located in /download/FireFox/firefox.exe


and I want somewhat like this www.domain.com/download.php?fi... as an output URL to download. I know that I can use MySQL and setup a nice database to do something like this as long as fileid is unique.


Any ideas on how to setup the MySQL database so that I can easily add multiple files from different sub directory at the same time.

Run Query From A File
I tried:

mysql> source 'file_name';

and

mysql> . 'file_name'

right now I'm running version 4.0.something on WinXP and I repeatedly get the following error:

Failed to open file 'file_name', error: 2

Any ideas?

How Do I Download Blob Files From My Database
I am developing a page where users can go to upload their CV'S (mainly word.doc) into my mysql backend. I have got it working and I am able to upload files to my table where i have a blob type for the files.

The problem is I don't understand how I can retrive these files I mean how can i view or download them.

I am currently working locally so when I go to phpmyadmin to view my files I don't know what to do. I know that they are there as I can see the following

[BLOB - 11 Bytes]
[BLOB - 12 Bytes]
[BLOB - 11 Bytes]
[BLOB - 14 Bytes]

So basically how can I download these files ....

Download To Excel Certain Info From Mysql
I run an oscommerce site, and want to download all the invoice details into a csv excel file.

the details that I need are in different tables, so i want to define exactly what I need
example

name, address, delivery name, order, vat ect

I have looked at various scripts on the internet, but cant seem to get anything to run.

Has anyone got a script, so I can just download the info that I need for my accounts.

How To Get Sql Query Result Into A File
can someone suggest me way to get large mysql select query into file? Is there a mysql built in function to do this? I know sybase have bcp to do this.

Query Output To Csv File
I'm using php/mysql for a website. One page the user can create a query to pull data from the database, but I want it to automatically save the data to a csv file. Is this possible, and how?

Using Query File From Console
I need to run a query written in a file from inside mysql console, not shell prompt.

Anyone can help me?

Using Query File From Console
I need to run a query written in a file from inside mysql console, not shell prompt...

SELECT Search Query - Table Join Required? Help Please!! (PHP + MySQL)
I have a search form that has:
- drop down with states (nsw, vic etc)
- drop down with all business categories (retail, commercial etc)
- keyword / postcode field (2000, or 'builders')

The user gets results returned from the business table filtered by state (mandatory), which category is selected (mandatory) and by keyword (optional) or postcode (optional).

If keyword / search phrase is given then it will do search of the keywords fields of the business table (has already been indexed) in the selected category only. If postcode it will return all businesses in that category in order of distance from the given postcode.

I have 5 tables (additional fields ommitted):

'state'
state_id, name

'businesses'
business_id, keywords, name, postcode, state

'postcodes'
fromPostcode, toPostcode, distanceKMS

'categories'
category_id, name

'business2category'
business_id, category_id

Please dont thing i'm just pawning off my work here!!
Basically, i've got this working already, but only just, and in a very long and convulted format. Its far too long to post here, but since i'm not fully versed in table joins, i've been searching individual tables (e.g. SELECT *,MATCH AGAINST etc), building arrays, searching arrays again, and then building results at the end to fit into the paginator. Now the search is taking too long to perform, and i need a leaner alternative. not to mention theres way too many lines of code, and i just know theres a better way.

There must be a very simple way to achieve the following searches using table joins, can anybody please help me with 3 search examples below so i can try to understand joins better?

Search 1:
State + Category only

Search 2:
State + Category + Keyword

Search 2:
State + Category + Postcode

If there is no postcode, the others still need to display the data
filtered by distance from a default postcode of 2000.

I'd really appreciate if anybody has a few minutes free to help out here, and hopefully teach me something about effective table joins and searching. I've omitted the extra fields and tables from the real structure, and just left the relevant ones above - if theres anyhing missing or not making sense please let me know and i'll fix up asap.


Copyright © 2005-08 www.BigResource.com, All rights reserved