Select Part Of Text Field
I want to get a snippet from a text field. I don't want the whole thing, just the first 200 characters, for example. Is this okay or is there a better way?
SELECT title, LEFT(body, 200) as body
FROM table.
View 4 Replies (Posted: August 29th, 2006, 05:56 PM)
Sponsored Links:
Related Forum Messages for MySQL:
Replace Part Of A Text Field With Text Stored In Another Table?
I want to be able to fix by running an sql query. I want to change just part of a string stored in 1 table with the correct value for that product and that value is stored in another table at present. Table1 name: wp_wpsc_product_files Fields: ID, Name, Description, Additional_Description Table2 name: wp_wpsc_productmeta Fields: ID, Product_ID, Meta_key, Meta_Value The Product_ID in the second table � is the link between the ID field in the wp_wpsc_product_files table The table wp_wpsc_productmeta where meta_key = SKU has the info I need in the meta_value field for each Product in the wp_wpsc_product_files table In the additional_description field (its a long text field type) there is a string of characters within a lot of other info � the string is: HDKLEPTO The HDKLEPTO string is in the additional_description field for every product in the product_files table. I need to replace this HDKLEPTO string with the products correct info from the productmeta table which has the correct info for each product In the meta_value field where the meta_key=SKU Pseudo-code:: Update wp_wpsc_product_files Set additional_description Replace within additional_description HDKLEPTO join wp_wpsc_product_files and Wp_wpsc_productmeta using product_id and ID field get meta_value for each product where meta_key = �SKU�
Posted: June 24th, 2010, 11:18 PM
View 3 Replies!
View Related
Replace Part Of Text Field With Text Stored In Another Table?
solve a little problem in my mysql database: Table 1 Name: wp_wpsc_product_files Fields: ID, Name, Description, Additional_Description Table 2 Name: wp_wpsc_productmeta Fields: ID, Product_ID, Meta_key, Meta_Value The Product_ID in the second table � is the link to the ID field in the wp_wpsc_product_files table. The table wp_wpsc_productmeta where meta_key = SKU has the info I need in the meta_value field for each Product in the wp_wpsc_product_files table In the additional_description field (its a long text field type) there is a string of characters within a lot of other info � the string is: HDKLEPTO. The HDKLEPTO string is in the additional_description field for every product in the product_files table. I need to replace this HDKLEPTO string with the products correct info from the productmeta table which has the correct info for each product. In the meta_value field where the meta_key=SKU Pseudo-code:: Update wp_wpsc_product_files Set additional_description Replace within additional_description HDKLEPTO with value from wp_wpsc_productmeta meta_value field join wp_wpsc_product_files and Wp_wpsc_productmeta using product_id and ID field Find meta_value where meta_key = �SKU� note: the additional_description field contains other strings of info that I don't want to loose...only want to replace that one string with the correct value for that particular product by find the value for that product in the product meta table.
Posted: Jun 25 10
View 2 Replies!
View Related
Select Part Of A Text On Db?
I have a column saved as LONGTEXT on mysql. This text saves rich text. I'm currently reading all the text then fixing it using javascript to get the first 100 characters in a way not to split the word in its middle. Yet this way don't seem the best way to do it. I want to select a summary directly using the query, yet I also want to be careful not to include characters that are html tags. The function below seems working fine to strip the html. SET GLOBAL log_bin_trust_function_creators=1; DROP FUNCTION IF EXISTS fnStripTags; DELIMITER | CREATE FUNCTION fnStripTags( Dirty varchar(4000) ) RETURNS varchar(4000).........
Posted: Aug 31 10 at 11:48
View 1 Replies!
View Related
SELECT TEXT FIELD
I want to do a SELECT query to display data from a TEXT field. It doesn't work with a simple SELECT statement and I've looked all over the books / documentation for the syntax but can't find anything. I keep getting a check syntax error. I want to display text data from a field called DESC in a Books table for a bookselling website as in : SELECT BOOK DESC FROM allbooks WHERE BOOK = Number ( BOOK is the ID number ) (I know that in an object based DB I have used there is a READ comand and a WRITE command to be used with text streams but how do you do it with SQL / MySQL ? )
Posted: April 25, 2007 08:31AM
View 4 Replies!
View Related
Getting Part Of A Text Column Value?
I have built a site from an html model the client made but, now, they want some of the product description text displayed elsewhere and so I need to store it in a different column because its relationship is different. how should my query look to grab the text shown in capitals? it's always at the beginning of the text block and it may or may not be in the same paragraph. it may be one or more sentences. I just want the sentence(s) in capitals and their respective full stops/periods. [code].... MySQL Code: SELECT * FROM product_range WHERE description REGEXP '[[:upper:]]+';
Posted: Jun 15, 2011, 16:47
View 2 Replies!
View Related
Grabbing A Substring Of A Field Where A String Matches Part Of The Field?
Ive been trying to find a fix to a SQL and PHP problem I have. below is a snippet of the table I am trying to work with. The table is called web_navbar_links the field is called slug +------------------+-------+ | slug | child | +------------------+-------+ |business-multiseat| 1 | +------------------+-------+ |consumer-multiseat| 1 | +------------------+-------+ I have a string "multiseat" I need an SQL query that will search all the rows and pull back the first substring "business" and/or "consumer" that match the string "multiseat" and are also child='1'.
Posted: Oct 11 10 at 11:21
View 1 Replies!
View Related
Regex - Query To Move Part Of 1 Field's Contents To A New Field
I have a table called cartypes which currently has 2 fields: id & type. I am adding subtype and I want to move the contents after the dash - from the field called type and put those contents into subtype. Disposing of the dash (any extra whitespace too for that matter). What's the best SQL query for this? before: id type subtype (currently empty) ------------------------------------------------------------------------------ 1 legendary muscle car - steel 2 crappy sedan - plasticky interior 3 legendary sports car - aluminum bodywork 4 compact car after: id type subtype --------------------------------------------------------------- 1 legendary muscle car steel 2 crappy sedan plasticky interior 3 legendary sports car aluminum bodywork 4 compact car
Posted: Oct 27 09 at 20:08
View 2 Replies!
View Related
Create A Field By Deleting A Part Of The String From Another Field!
I have a table for "Addresses", which has a column titled "Address" and the records in this column are a combination of house#, street name and street suffix, which typically looks like "100 Main Street". I am looking for a query result wherein a new column would be created which would have only the street name and the suffix and would eliminate the house #s, hence the result would look like "Main Street".
Posted: 04-07-2005, 03:45 PM
View 2 Replies!
View Related
Db Full-Text Search - Searching For Part Of A Keyword?
I've read about full-text search functions in mysql. But in these methods you have to search for exactly right spelled complete words. For example if your text contains 'Bitdefender 2009' and you search for Bit, you get nothing SELECT * FROM logs WHERE MATCH (log) AGAINST ('Bit 09' IN BOOLEAN MODE); So are there any solution for this? (Is there a technique which would let you search for misspelled keywords as well? for example you search for Bitdefedner)
Posted: Jul 7 10 at 9:24
View 3 Replies!
View Related
Deleting Part Of A Field
i have a table called, videos, and a in that table i have description fields, that all contain a description followed by {video}randomnumbers{/video} and i want to delete the {video} + {/video} and the random numbers between but leave the other parts of the fields,
Posted: April 22, 2009 11:15AM
View 2 Replies!
View Related
Update Part Of Field?
I have following fields +--------------------+ | field | +--------------------+ | one 111 | | one 123 | | one 222 | | one 234 | +--------------------+ I need to change "ont" to "two without changing rest. How can I get result? +--------------------+ | field | +--------------------+ | two111 | | two 123 | | two 222 | | two 234 | +--------------------+ I know update but in this case I don't know how to use it.
Posted: February 13, 2010 08:27AM
View 2 Replies!
View Related
Sort By Numeric Part Of A Field
I must sort a table width only one column. Inside the field I have, for example, hard disk capacity (something like '100Gb' or '80Gb' or '80Gbyte' or 'Gb80'). So, if I use ORDER BY ... DESC, 80Gb will be before 100Gb and other errors. How can i sort the table only on the numeric part of the field? I'm trying using CAST() but with no results.
Posted: July 26th, 2006 10:35 AM
View 3 Replies!
View Related
Update Query For Part Of A Field
I need to update part of a field in around 3000 rows of a table. In each case the field in question has text already in it but I need to add an extra bit of text to the start of each one. I've had a look on the web and have found examples that show you how to replace text in part of a field but haven't found anything about adding new text.
Posted: November 3rd, 2008, 09:28 AM
View 5 Replies!
View Related
Editing Part Of Field In MySQL
I exported an excel database with no number formatting to a comma delimited txt file and imported it into mySQL. The database contains 24000 rekords. For some reason some 3000 odd rekords were imported with .00 decimals. Is there a way through a SQL query that I can delete ONLY the incorrect .00 data from multiple fields? I don't exactly look forward to manually editing 3000 rekords!
Posted: 01-07-2004, 08:25 PM
View 1 Replies!
View Related
How Do I Update Part Of A String Value In A Field
I have information in a field as follows: |___col___| | AAXXAAA | I need up update all instances of the substring 'XX' in the 'col' field to 'YY', but I do not know how to structure the SET portion of my update statement to do this. Below is my update statement minus the set portion. UPDATE db.table SET col = <need help> WHERE col LIKE '%XX%';
Posted: April 13, 2006 03:48PM
View 1 Replies!
View Related
Display Only Part Of A Field Using A Regex?
I have a field called 'url'In it, there are many url's, they are all in different formats.y all have tracking ID's on the end however...I want to only view the tracking ID's...The tracking ID's are all different... BUT they have 2 things in common... they are always near the end of the string, and they are exactly 6 charchters long....So I'd like to use a regex that:1. Starts searching from the right of the string2. finds the first occurrence of 6 uninterrupted alphanumeric characters3. Displays those characters to the user.From what I've read about regex's and mysql, the regex function only ever returns true/false for use in a where clause.s there anyway to accomplish what I'm trying to do in sql land?I'd post examples of the URL's I'd like to parse, but new users can't do that :-(
Posted: January 11th, 2010, 04:31 PM
View 2 Replies!
View Related
INSERT INTO SELECT Taking Forever But SELECT Part Is Fast?
I have the following mysql code to insert about a million rows. This takes quite a long time (over 50 min). However, when I just run the query alone without the INSERT command, the query itself only takes under 5 minutes. Is there a way I could speed up the inserting?? insert into tblc select tbla.* from tblb inner join tbla on tbla.issuer_id = tblb.issuer_id;
Posted: July 28, 2008 05:31PM
View 3 Replies!
View Related
Create Index On Date Part Of DATETIME Field?
How do I create an index on the date part of DATETIME field? mysql> SHOW COLUMNS FROM transactionlist; +-------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------+------+-----+---------+----------------+ | TransactionNumber | int(10) unsigned | NO | PRI | NULL | auto_increment | | WagerId | int(11) | YES | MUL | 0 | | | TranNum | int(11) | YES | MUL | 0 | | | TranDateTime | datetime | NO | | NULL | | | Amount | double | YES | | 0 | | | Action | smallint(6) | YES | | 0 | | | Uid | int(11) | YES | | 1 | | | AuthId | int(11) | YES | | 1 | | +-------------------+------------------+------+-----+---------+----------------+ 8 rows in set (0.00 sec) TranDateTime is used to save the date and time of a transaction as it happens My Table has over 1,000,000 records in it and it and the statement SELECT * FROM transactionlist where date(TranDateTime) = '2008-08-17' Takes a long time.
Posted: Sep 18 08 at 18:15
View 9 Replies!
View Related
UPDATE Command To Alter 'part' Of A Field Entry?
I need to work out what SQL command I use to update (replace) only part of a field. Is this possible? Example: I have a load of records like this in a table called 'contacts' ID: 1 First Name: Joe Last Name: Bloggs Email: something@something.com Website: <a href="www.website.com">Link</a> How do I change every record in my database so the end part of Website records say ... >Website</a> instead of >Link</a> ? Im guessing the command would start with UPDATE contacts SET website ='>website</a>' WHERE website {some command here} '>link</a>'
Posted: March 11, 2011, 05:56:41 AM
View 3 Replies!
View Related
|