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




Query Two Tables For A Word


I have a table of words (dict), a basic dictionary. And i have a spell check page that will check if words are in the dictionary using this query:

select * from dict where words = '$Words[$W]'

I want to add a secondary table (dictlearn) with new words that the use can add. When I try this I keep getting an ambiguous error for words:

select * from dict, dictlearn where words = '$Words[$W]'

How can I query both tables for a word to see if there are any matches in either table?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Use Where In Query So It Returns Rows That Has Less Than 10 Characters In The Word
I want to return rows that has less than 10 characters in the word that is used in the where clause sort of thing.

I can't really explain so I will give you an example, which is obviously wrong.

Quote:

mysql_query("select games from gaming where gamename < 10 characters");

Key(e) Which Is In Middle Position Of A Word And In Last Of The Word
code

select id,myString
from myTable
where
myString like '%e%'

result

(1) I love you
(2) Here we go
(3) Nice to meet you
(4) mell me.
I have myTable like the above.

I like to produce only the record which has the key(e) is in middle position of a word and in the last position of the word.

The following trial code doesn't work correctly, but it will show what I want.

trial code

select id,myString
from myTable
where
myString like '% %e%e %'

result

NONE

target result

(2) Here we go.

I Need To Index The 'once' Word
I am working with mysql server 5.0 an I have an Index in a database
table,

but I need to index the word 'once'. My index it's not indexing it
because once is a number... How can I configure Mysql or the index to
index this word?

My index is Fulltext type.

Restricted Word?
I'm trying to install snort using prewritten scripts. One of the tables that
they are trying to create has a column named "timestamp".... Which MySQL barfs
all over the scrip when I try to run it and gives me parsing errors....

I've renamed the column and the script will run then... So my question is this... Is
the word "timestamp" a restricted word or something... I couldn't find anything
that said it was.

Replace Word
I would like to know that is there any way to replace the particular word from the sentence by using Mysql query.

For e.g.->
I have records in the Mysql table like…

CodeParticulars
101This is the $abc. I am $xyz for help.

In the above records, I would like to replace
$abc – Help topic
And
$xyz – searching

Word Count
Is there a function to perform a word count, or count the occurences of string w/i a field?

Mysql With MS Word
I have been trying to find a way to copy data tables from MS Word to MySql through a php interface i have created.

until now i just found pre, css with white-space, wordwrap() and etc. Is there any programming way to achieve that? Does anybody know of any similar application or a better way

SQL For One Word In A Sentence
Suppose I have a field(A) in my table(Tab) which has a sentences like
"I work for a major company"
Now in my select statment I want to pick only those records where field "A" has word "major" in it..
How do i do that?
I thought there was some 'Any' operator

Restricted Word
I'm trying to install snort using prewritten scripts. One of the tables that
they are trying to create has a column named "timestamp".... Which MySQL barfs
all over the scrip when I try to run it and gives me parsing errors.... I've
renamed the column and the script will run then... So my question is this... Is
the word "timestamp" a restricted word or something... I couldn't find anything
that said it was

Certain Word/symbol
Im quite new to this whole mysql stuff, and im trying to sort something out. I've allready searched google/this forum, but couldnt find a fitting solution to my problem:
I have a table in my database called jos_content (joomla website), which contains all news articles from my site. Each newsarticle has a exclamation-mark in the title (its allready in the rssfeed). I want to delete this exclamation-mark from each newsarticle automatically. Is there any SQL command to do this ? If so, can i put the command in a php file and run a cron job every 10 minutes or so

Replacing A Word
I searched for the answer to this, but gave up. The MySQL manual gives a REPLACE() string function, but I don't quite get it. I need to find 'ALL-' in a my 'dept' cell of every record and replace it with 'NEW-'.

I don't understand how SELECT REPLACE('www.mysql.com', 'w', 'Ww'); would do this.

Excluding A Word
I am combining to columns, Home_team and away_team.


Code:


concat(`games`.Away_team,`games`.Home_team) as Opponent

So the result is "TeamATeamB" I am only tracking my team, so I would like the opponent column to exclude "TeamB" (my team). Is this possible?

A Word Across All Fields.
Can someone write a simple SQL syntax to give all the records containing a given word? Is like a primitive search engine

Word Index
I would like to know if there is a way of building an index on all the words
of a column.We want to have an alphabetical search on all the words of a description of
a product.So, how I treat this index when I change a part of the content of this
specific column where I want a word index

Create Single Query From Queries On Two Tables (was "Help With Query...")
I read from other thread that query inside loop is not good idea. May I ask some help how can I create a single query to the following code which I use loop.

$sql = "SELECT * FROM mytable order by points desc limit 10";
$rec = mysql_query($sql) or die(mysql_error());
$datas = mysql_fetch_array($rec);

do{
$sq = "Select * from secondtable where linkid = '$datas[id]'";
$rst = mysql_query($sq) or die(mysql_error());
$rows = mysql_fetch_array($rst);
echo "$rows[somefield]";
}while($datas= mysql_fetch_array($rec));
This works perfectly but I want the second query to be out of the loop if there is a way and how.

Count Word In A Text
hello everybody.
could someone tell me if there is a way of counting a word in a filed from a table using a subquery?

examle.
let's say i have the following text in $row[description]

Quote:

"Before posting on these forums, please read the Rules and Information page. It will make your life here easier. Is that clear or is not clear. Maybe you need to make a change in your life. Bla bla"

Ok, now the sql

PHP

$sql=mysql_query("select * fields form $table where description like %$word%");
$results = mysql_num_rows($sql);

let's say we have 3 results, (1, 2, 3) but in the first result the $word appears 5 times and in 2, 3 the $word apears less times.
The question is hou could I order the results DESC ?
hope I made my self clear.
thx

Return Is Reserved Word In 5.x?
I had a table called Return, which as of 4.09 was working just fine, when I moved into 5.0 the table refuses to be created because (it appears) return is a reserved word? Can anyone confirm?

New Reserved Word 'force'
I have a database in which one column is titled 'force'. Now that
this has become a reserved word, virtually no commands will execute,
including of course a query to change the column name.

Delete Certain Word In All Records ?
I have a table in my database called jos_content (joomla website), which contains all news articles from my site. Each newsarticle has a exclamation-mark in the title (its allready in the rssfeed). I want to delete this exclamation-mark from each newsarticle automatically. Is there any SQL command to do this ? If so, can i put the command in a php file and run a cron job every 10 minutes or so?

Number Of A Certain Word In A String
example: i want to search for the word "word1" on this string:

"word1 test test test string2 word1 string3 word1"

The result should be 3 since there were 3 "word1" on that string..

Its like returning the number of words that that string have, this string of course is stored in the database.

Upload MS Word Files
I have created an upload script to enable people to upload MS Word documents to the MySQL server.

Uploading basic word files with just text in works fine. I am having a problem with uploading files which contain images as well as text. Is the MySQL database not able to receive a mixed text and image file or is there a way round the problem.

Replacing Word From Fields
I have a large DB full of 98% acceptable content. I want to replace all the swears within a field. I want to select all the fields that contain, say, "f..." and replace with another word like "fudge" or something. I don't want to delete the row because it is much needed content.

Word Boundry MYSQL
Is it possible to search a MYSQL database for exact word mactches like this?

$q is the variable that holds the search word
$q=$_GET['q'];
$result = mysql_query("SELECT * FROM product WHERE (cat LIKE '$q' OR dsc LIKE '$q' OR title LIKE '$q' OR pic LIKE '$q')",$db);

I'm trying to match exact words, not partial words, can I do that straight through MYSQL or do I have to match against it in PHP?

Uploading A Word Document
i've researched this topic extensively and every bum that thinks he knows how to do it runs into the same issue, when uploading the file into a blob or medium blob through opening it, reading its content, adding slashes and then placing it in the datafield it gets all junked up with crazy characters and salvaging any amount of useful information is impossible.
So does anyone have an example of how to properly upload a word document into a mySQL data field blob or medium blob?

Microsoft Word Interface
I am developing an online app that helps many editors review articles, check for errors, add new articles, etc. The editors are used to using Word to help them go through several articles at once. Because of this, I'm hoping to figure out a way to allow several persons access to their content on a MySQL database online via their local install of MS Word.

I have been working some with the OBDC mysql provides at http://www.mysql.com/products/connector/odbc/ (ver 3.51) and have been able to connect and retrieve some data. My problem is how do I update the users' articles online after they have finished reviewing them in MS Word?

MySQL And MicroSoft Word
We are trying to allow someone to use MicroSoft Word on their computer to update the MySQL databasse on a remote server. Nothing is working.  Any idea what we need to do to accomplish this

Search From Beginning Of Word In Field.
I have "name" field with the values : "apple", "banana", and "apple and banana".

I want to query that strings and find the string "an".

If i query `name` LIKE '%an%' it will return allso the "banana" - i want just "and"

It is a problem for me because I want to search the words in the "name" field.
The query should search from the beginning of each word. haw can i do this ?

How To Search For Part Of A Word In FULLTEXT
for WHERE, we use LIKE '% %', but what about FULLTEXT?

How To Get Stop Word List In Mysql
I want to use the stop word list of my sql in my program. How can I get this list in sql. Is it stored in some table in database. How can I access it using a query.

Word Counts From Text Field
I want to calculate the numbers of occurances of a word in a text type table filed in mysql query.

For ex. say filed name content in a pages table have value "This is a very good site" then query for "is" word shoud return 2.

CALL Table - Reserved Word?
I've just installed 5.0.18 and trying to query a table I have called CALL.

i.e. SELECT * from CALL

And receive an ERROR 1064 (42000) Syntax Error message

I've used previous versions of MySQL without problem, but I'm guessing that CALL may now be a reserved word (ok its not the wisest name for a table in hindsight!)

It is possible to disable the CALL function or allow me to query the CALL table somehow (without renaming it!)

Otherwise I guess its a case of reverting back to a previous version of MySQL.

Create A Stop Word File
I need to change the stop word file used by the MySQL in fulltext seach.

The documentation (www.mysql.com/doc/en/Fulltext_Fine-tuning.html)
explains how to inform to MySQL the new stop word file through the
"ft_stopword_file" variable.

But I could not find any reference to the layout of this file, for
example, how to separate each stop word in the list?

Does someone have any experience on that?

Echo To Text Box - Only First Word Returned
I'm echoing values from a db to text boxes, but only the first words are returned. The db field is set to varchar(255). Can someone please tell me how to solve this small but annoying problem? Thanks. By the way, I don't have any regular expressions or that kind of coding: I don't understand them :p.

Count Word Within Varchar Field
I like to count the occurences of a word within a varchar field.

Let's say I have the following table

Table: content
Field 1 : id (int auto incr)
Field 2 : IntroText (varchar 255)

I like to search on the word "monitor"

So the query should be

SELECT id, IntroText FROM content WHERE IntroText like 'monitor'

But now, I also would like to know the number occurrences within IntroText for each found row.

Mysql Longtext Php Word Wrap
Just did a search for this on coding forums, thought I would have found something but perhaps not.

In a mysql database I have a longtext, an example of whats held in it ...

here is my long text.
this is some random ...
... text that is
in the long text field.

problem is, when i print it to a page in php I get ..

here is my long text.this is some random ... ... text that is in the long text field.

As if its something like wrapping the words? it doesnt seem to break for new lines. I have entered the long text value using a html textarea field but also tried it straight from phpmyadmin ...
when looking at it in phpmyadmin and sqlyog, it looks fine, it has the correct formatting .. im just putting the result $row[whatevr] into a $string .. and then echo $string and it loses all the formatting.

Min Word Length Full Text Search
is there any way i can change the min word length in a mysql query?

I might not have access to my msql ini files so, is there any way to changee this in the query?

Fulltext Search Using Wildcard At *beginning* Of Word?
select * from MyTable where match (MyContent) against('*my_keyword*' in boolean mode)

does NOT work... the documentations says the * wildcard can only be added at THE END of a string to truncate it, so

select * from MyTable where match (MyContent) against('my_keyword*' in boolean mode)

would work, but then searches where the keyword is something like 'off' would not return things like 'coffee' only things like 'office'...

Is there a way to create wildcards for the beginning of words?

Storing Pdf/word Documents In The Mysql Database
i want to know that, weather pdf and msword documents can be stored in mysql database directly or not?

because i'm not using any connectors, i'm able to write and retrieve the contents of the word and pdf using byte stream in java.

but the contents were not stored in proper format. it looks like junk values. i'm able to store images and text based documents properly.

Full Text Search Min Word Length
I am using fulltext searches and they are working fine. We have set
ft_min_word_length to 3.

However, some users need to search for two-letter words, and we are not
sure if we should change ft_min_word_length to

ft_min_word_length=2

Does changing ft_min_word_length from 3 to 2 have a large impact on
query response times? What about index size? CPU usage?

Export MySQL Database To Word Document
This is something I've seen on forums like Invision Power Board, there is an option to save the thread as a document. What I have is a PHP/MySQL system that has contact details for around 2000 people, far too many to have in one print view page. The entries are limited to 100 per page, after a 100 entries the PHP script creates additional pages by calling the next 100 entries with the $_GET function.

For the entire thing there's about 20 pages. What i want to do is have a simply link option that can be clicked which pulls all the records from the database and exports them as a Word document which you can save to your desktop and preferrably have the ability to define the formatting of the page within the PHP so you can define what text will be bold how it will be aligned, ow the records will be ordered etc. Does anyone know of a way to do this?

Using Many Tables In A Query
I'm developing a script, which creates a bunch of tables for each registered member. And I need to sum up some statistical information, like records count, based on tables of each user, say: user1_posts, user2_posts and so on.

How efficient would it be to use a query with its from clause consisting of thousands of tables in this case? Should I look for another way to do this?

Need To Query Two Tables
I am new to MySQL, but I'm sure the pros here can figure this one out pretty easily.

There are two tables; one that lists all of the clicks from all members and one that lists all of the links.

Basically, when the member logs in I want them to see a list of links that they have not clicked on.

The clicks table has a user_id and link_id column.
The links table has the link_id column and some other info.

Can You Query Against 2 Tables?
In one table I have a list of users and in the other a register to keep track of when they are in. The query I need to build will check that the user belongs to a particular group (in the user table) AND that there is no data against there name for today i.e. date("YY/mm/dd") in the register table....

Two Tables--One Query
I've got two tables: carddb_games and carddb_cards. Their structures are like so:Code:

carddb_games {
game_id tinyint(3)
game_name tinytext
}
carddb_cards {
card_id smallint(5)
game_id tinyint(3)
card_num tinytext
card_name tinytext
card_effects tinytext
card_special tinytext

Is it possible to make a query such that it will go through each game in carddb_games AND return a count of how many cards exist with a matching game_id within the carddb_cards table?
I am not sure as to how to go about it, if such is even possible.

Two Tables In One Query
i'd love if anyone could help me out on the following situation:
I do have a db with two tables for price comparisations - my example:table 'items' contains an entry with the itemno '123' and a basic price of '5.00' plus additional stuff like description etctable 'prices' contains 3 entries for the itemno '123' with the prices '6.00', '10.00' and '20.00'
Now i need to catch several data from the table 'items' and additionally the highest price for the item '123' in one query.
The tricky thing is, that an item possibly could have no entries in the 'prices' table and in that case the kinda default price from the table 'items' should be taken.

REGEXP: Search String Where All Words Have Word Boundaries
I want to search a column using a search string where all words have word boundaries and each word MUST be included in the search result.. but using only 1 call to REGEXP per column

so instead of:
WHERE column1 REGEXP '<word_1>' AND column 1 REGEXP '<word_2>'

is there a way to do this?:
WHERE column1 REGEXP '<word_1>(and?)<word_2>'

i ask because there is an OR ( | ) available, maybe there's an 'and' as well? I can't seem to find it. I'm searching 3 columns and i'm just looking for a way to avoid generating 10+ REGEXP's for the search string.

COUNT() 2 Tables In 1 Query
So I have these two queries:

$result= mysql_query("SELECT YEAR(add_date), MONTH(add_date), COUNT(*) FROM clogsyn_track_main where user_id='$uid' GROUP BY YEAR(add_date),MONTH(add_date)");

$result2= mysql_query("SELECT YEAR(add_date), MONTH(add_date), COUNT(*) FROM clogsyn_track_pop where user_id='$uid' GROUP BY YEAR(add_date),MONTH(add_date)");

They output data like
Month Year, Total Views
So I can see how many total times a page was visited that month for a specific user_id.

The problem is I'm tracking 2 sections of the site "main" and "pop" which pop is a unique page that pops up when something is clicked.

I tried EVERY way to join them together but the count(user_id) doing a LEFT JOIN kept adding the count()'s from both tables together.

Is it not possible to do a count() on two tables in 1 query?

Here's one of the many combined I tried.

$sql = "SELECT a.user_id,b.user_id,YEAR(a.add_date),MONTH(a.add_date),COUNT(a.add_date),COUNT (b.add_date) FROM clogsyn_track_main a LEFT JOIN clogsyn_track_pop b ON a.user_id=b.user_id AND YEAR(a.add_date)=YEAR(b.add_date) AND MONTH(a.add_date)=MONTH(b.add_date) WHERE a.user_id='$uid' GROUP BY YEAR(a.add_date),MONTH(a.add_date)";

Can anyone help me here or is it not possible to do it in 1 query?

Need Query To Join 2 Tables Through A 3rd
I have a table called client (primary key = clientID), another called clientFamily (pk = clientFamilyID) and a table that joins those two called client2clientFamily. The latter table only has two rows: clientID and clientFamilyID (no pk).

On the client table, say the client has 3 children and 2 siblings. Those would go on the clientFamily table. The part I don't know how to do is how to assign those 3 kids and 2 sibs to that particular client. I know I do it via the client2clientFamily table but I don't know the query.

I'm also not sure I'm thinking of this right. The fields on clientFamily start off like:

clientFamilyID
spouseFirstName
spouseMiddleName
spouseLastName
spouseOccupation
motherFirstName
motherLastName
motherOccupation
fatherFirstName
fatherLastName
fatherOccupation

I think that part's ok, but if I add:

childFirstName
childLastName
childBirthday
childSex

and

sibFirstName
sibLastName
sibOccupation

how are, for example, a child's birthday and sex are going to be linked to the correct child? And a sib's occupation linked to the correct sib? Now I'm wondering if I need a separate table for clientChildren (and a joining table client2clientChildren) and another one for clientSibs (& client2clientSibs) instead of putting everything in clientFamily. Ugh.

Get 4 Tables Data In One Query
I am new to mysql relational programming, and creating a tutorial site like pixel2life. I am trying to get the data from 4 tables 1st table is main tutorials table, 2nd is subcategory (subcat) table, 3rd is categories table and 4th is users table. I don't know how to do it exactly, I googled but not got the proper method. I only got some hints http://www.brainbell.com/tutorials/M...ing_A_Join.htm from this site. I've created the following query which selects the title from tutorials table, subcategory (s_cat) from subcat table which reference is available as s_cat_id in tutorials table, then category (cat) from categories table which reference is available in subcategory (subcat) table and username from users table which reference is availble in tutorials table. Can somebody tell me this query is correct or there is any alternate method

PHP

SELECT d.title, s.s_cat, c.cat, u.username FROM tutorials d
JOIN subcat s ON d.s_cat_id=s.id
JOIN categories c ON s.cat_id=c.id
JOIN users u ON d.author_id=u.id


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