Search Results

Search found 23568 results on 943 pages for 'select'.

Page 13/943 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • MySQL: Request to select the last 10 send/received messages to/by different users

    - by Yako malin
    I want to select the 10 last messages you received OR you sent TO different users. For example the results must be shown like that: 1. John1 - last message received 04/17/10 3:12 2. Thomy - last message sent 04/16/10 1:26 3. Pamela - last message received 04/12/10 3:51 4. Freddy - last message received 03/28/10 9:00 5. Jack - last message sent 03/20/10 4:53 6. Tom - last message received 02/01/10 7:41 ..... Table looks like: CREATE TABLE `messages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `sender` int(11) DEFAULT NULL, `receiver` int(11) DEFAULT NULL, `content` text ) I think Facebook (and the iPhone) use this solution. When you go to your mail box, you have the last messages received/sent grouped by Users (friends). So I will take an example. If I have theses messages (THEY ARE ORDERED YET): **Mike** **Tom** **Pam** Mike Mike **John** John Pam **Steve** **Bobby** Steve Steve Bobby Only Message with ** should be returned because they are the LAST messages I sent/received By User. In fact I want the last message of EACH discussion. What is the solution?

    Read the article

  • PHP DELETE immediately after select

    - by teehoo
    I have a PHP server script that SELECTs some data from a MySQL database. As soon as I have the result from mysql_query and mysql_fetch_assoc stored in my own local variables, I want to delete the row I just selected. The problem with this approach is that it seems that PHP has done pass-by-reference to my local variables instead of pass-by-value, and my local variables become undefined after the delete command. Is there anyway to get around this? Here is my code: $query="SELECT id, peerID, name FROM names WHERE peer = $userID AND docID = '$docID' AND seqNo = $nid"; $result = mysql_query($query); if (!$result) self::logError("FAIL:1 getUsersNamesUpdate() query: ".$query."\n"); if (mysql_num_rows($result) == 0) return array(); $row = mysql_fetch_assoc($result); $result = array(); $result["id"] = $row["id"]; $result["peerID"] = $row["peerID"]; $result["name"] = $row["name"]; $query="DELETE FROM names WHERE id = $result[id];"; $result = mysql_query($query); if (!$result) self::logError("FAIL:2 getUsersNamesUpdate() query: ".$query."\n"); return $result;

    Read the article

  • mysql select update

    - by Tillebeck
    Hi I have read quite a few selcet+update questions in here but cannot understand how to do it. So will have to ask from the beginning. I would like to update a table based on data in another table. Setup is like this: - TABLE a ( int ; string ) ID WORD 1 banana 2 orange 3 apple - TABLE b ( "comma separated" string ; string ) WORDS TEXTAREA 0 banana -> 0,1 0 orange apple apple -> BEST:0,2,3 ELSE 0,2,3,3 0 banana orange apple -> 0,1,2,3 Now I would like to for each word in TABLE a append ",a.ID" to b.WORDS like: SELECT id, word FROM a (for each) -> UPDATE b SET words = CONCAT(words, ',', a.id) WHERE b.textarea like %a.word% Or even better: replace the word found in b.textarea with ",a.id" so it is the b.textarea that ends up beeing a comma separeted string of id's... But I do not know if that is possible.

    Read the article

  • Create Duplicate Records on SELECT for Calendar Date Range

    - by peterallcdn
    Hey all, I've built a pretty shnazzy calendar system but there is one tweak that I need to make so that I'm completely happy with it. My calendar has three tables: calevents - The calendared event. caldates - The occurrences and date-range of each occurrence for each event. calcats - The categories that can be applied to an event. The short: For each calevent, there can be many caldates, one for each occurrence of calevent. So a calevent that repeats weekly and spans 3 days might have caldates like this: date_id date_eid date_start date_end 2 37 2010-06-21 2010-06-23 3 37 2010-06-28 2010-06-30 7 37 2010-07-05 2010-07-07 9 37 2010-07-12 2010-07-14 What I want to do, is when selecting all the caldates for a specified month such as 2010-06, to return not just the two records above, but instead a record for each date in the range of date_start and date_end for each caldate. So if I searched for 2010-06, I would get: date_id date_eid date_start date_end date_day 2 37 2010-06-21 2010-06-23 2010-06-21 2 37 2010-06-21 2010-06-23 2010-06-22 2 37 2010-06-21 2010-06-23 2010-06-23 3 37 2010-06-28 2010-06-30 2010-06-28 3 37 2010-06-28 2010-06-30 2010-06-29 3 37 2010-06-28 2010-06-30 2010-06-30 The Long: The reason I want to do this, is so when displaying a list of events(calevents) for a specified month, an occurrence(caldates) of that event will be displayed for EACH of the days it spans. I could do this with php by looping through each day of the current month and displaying a copy of each caldate if the month day falls between date_start and date_end. But doing it this way will prevent me from using record pagination if needed. For example, if for a specified month the following caldates were returned: date_id date_eid date_start date_end 2 37 2010-06-21 2010-06-27 94 53 2010-06-09 2010-07-08 Doing record pagination would see this as only 2 records("rows"). But looping through them with PHP would generate 29 "rows". So, I figure if I use mysql to create each row instead of PHP, I can achieve the same thing AND still be able to use pagination if a month has a lot of events/dates. As far as performance goes, I'm not sure which option is more efficient. Both would send the same amount of info to the browser, so it's really only the work required to generate the info that matters. My current query which fetches all the occurrences for a specified month, and to make things just a little more complicated... joins them with their event and category, looks like this: $sql_to_execute = " SELECT date_id, date_eid, date_start, date_end, event_id, event_title, event_category, event_private, event_location, SUBSTRING_INDEX(event_detailsstripped, ' ', 40) AS event_detailsstripped, event_time, event_starttime, event_endtime, event_active, cat_colour FROM ( caldates LEFT JOIN calevents ON caldates.date_eid = calevents.event_id ) LEFT JOIN calcats ON calevents.event_category = calcats.cat_id WHERE date_start <= '".mysql_real_escape_string($dbi_list_end_date)."' AND date_end >= '".mysql_real_escape_string($dbi_list_start_date)."' ".$dbi_category." ORDER BY date_start ASC "; Any help or advice would be greatly appreciated! Thanks, Peter

    Read the article

  • Database with 5 Tables with Insert and Select

    - by kirbby
    hi guys, my problem is that i have 5 tables and need inserts and selects. what i did is for every table a class and there i wrote the SQL Statements like this public class Contact private static String IDCont = "id_contact"; private static String NameCont = "name_contact"; private static String StreetCont = "street_contact"; private static String Street2Cont = "street2_contact"; private static String Street3Cont = "street3_contact"; private static String ZipCont = "zip_contact"; private static String CityCont = "city_contact"; private static String CountryCont = "country_contact"; private static String Iso2Cont = "iso2_contact"; private static String PhoneCont = "phone_contact"; private static String Phone2Cont = "phone2_contact"; private static String FaxCont = "fax_contact"; private static String MailCont = "mail_contact"; private static String Mail2Cont = "mail2_contact"; private static String InternetCont = "internet_contact"; private static String DrivemapCont = "drivemap_contact"; private static String PictureCont = "picture_contact"; private static String LatitudeCont = "latitude_contact"; private static String LongitudeCont = "longitude_contact"; public static final String TABLE_NAME = "contact"; public static final String SQL_CREATE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + "(" + IDCont + "INTEGER not NULL," + NameCont + " TEXT not NULL," + StreetCont + " TEXT," + Street2Cont + " TEXT," + Street3Cont + " TEXT," + ZipCont + " TEXT," + CityCont + " TEXT," + CountryCont + " TEXT," + Iso2Cont + " TEXT," + PhoneCont + " TEXT," + Phone2Cont + " TEXT," + FaxCont + " TEXT," + MailCont + " TEXT," + Mail2Cont + " TEXT," + InternetCont + " TEXT," + //website of the contact DrivemapCont + " TEXT," + //a link to a drivemap to the contact PictureCont + " TEXT," + //a photo of the contact building (contact is not a person) LatitudeCont + " TEXT," + LongitudeCont + " TEXT," + "primary key(id_contact)" + "foreign key(iso2)"; and my insert looks like this public boolean SQL_INSERT_CONTACT(int IDContIns, String NameContIns, String StreetContIns, String Street2ContIns, String Street3ContIns, String ZipContIns, String CityContIns, String CountryContIns, String Iso2ContIns, String PhoneContIns, String Phone2ContIns, String FaxContIns, String MailContIns, String Mail2ContIns, String InternetContIns, String DrivemapContIns, String PictureContIns, String LatitudeContIns, String LongitudeContIns) { try{ db.execSQL("INSERT INTO " + "contact" + "(" + IDCont + ", " + NameCont + ", " + StreetCont + ", " + Street2Cont + ", " + Street3Cont + ", " + ZipCont + ", " + CityCont + ", " + CountryCont + ", " + Iso2Cont + ", " + PhoneCont + ", " + Phone2Cont + ", " + FaxCont + ", " + MailCont + ", " + Mail2Cont + ", " + InternetCont + ", " + DrivemapCont + ", " + PictureCont + ", " + LatitudeCont + ", " + LongitudeCont + ") " + "VALUES (" + IDContIns + ", " + NameContIns +", " + StreetContIns + ", " + Street2ContIns + ", " + Street3ContIns + ", " + ZipContIns + ", " + CityContIns + ", " + CountryContIns + ", " + Iso2ContIns + ", " + PhoneContIns + ", " + Phone2ContIns + ", " + FaxContIns + ", " + MailContIns + ", " + Mail2ContIns + ", " + InternetContIns + ", " + DrivemapContIns + ", " + PictureContIns + ", " + LatitudeContIns + ", " + LongitudeContIns +")"); return true; } catch (SQLException e) { return false; } } i have a DBAdapter class there i created the database public class DBAdapter { public static final String DB_NAME = "mol.db"; private static final int DB_VERSION = 1; private static final String TAG = "DBAdapter"; //to log private final Context context; private SQLiteDatabase db; public DBAdapter(Context context) { this.context = context; OpenHelper openHelper = new OpenHelper(this.context); this.db = openHelper.getWritableDatabase(); } public static class OpenHelper extends SQLiteOpenHelper { public OpenHelper(Context context) { super(context, DB_NAME, null, DB_VERSION); } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL(Contact.SQL_CREATE); db.execSQL(Country.SQL_CREATE); db.execSQL(Picture.SQL_CREATE); db.execSQL(Product.SQL_CREATE); db.execSQL(Project.SQL_CREATE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); db.execSQL(Contact.SQL_DROP); db.execSQL(Country.SQL_DROP); db.execSQL(Picture.SQL_DROP); db.execSQL(Product.SQL_DROP); db.execSQL(Project.SQL_DROP); onCreate(db); } i found so many different things and tried them but i didn't get anything to work... i need to know how can i access the database in my activity and how i can get the insert to work and is there sth wrong in my code? thanks for your help thats how i tried to get it into my activity public class MainTabActivity extends TabActivity { private Context context; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maintabactivity); TabHost mTabHost = getTabHost(); Intent intent1 = new Intent().setClass(this,MapOfLight.class); //Intent intent2 = new Intent().setClass(this,Test.class); //Testactivity //Intent intent2 = new Intent().setClass(this,DetailView.class); //DetailView Intent intent2 = new Intent().setClass(this,ObjectList.class); //ObjectList //Intent intent2 = new Intent().setClass(this,Gallery.class); //Gallery Intent intent3 = new Intent().setClass(this,ContactDetail.class); mTabHost.addTab(mTabHost.newTabSpec("tab_mol").setIndicator(this.getText(R.string.mol), getResources().getDrawable(R.drawable.ic_tab_mol)).setContent(intent1)); mTabHost.addTab(mTabHost.newTabSpec("tab_highlights").setIndicator(this.getText(R.string.highlights),getResources().getDrawable(R.drawable.ic_tab_highlights)).setContent(intent2)); mTabHost.addTab(mTabHost.newTabSpec("tab_contacts").setIndicator(this.getText(R.string.contact),getResources().getDrawable(R.drawable.ic_tab_contact)).setContent(intent3)); mTabHost.setCurrentTab(1); SQLiteDatabase db; DBAdapter dh = null; OpenHelper openHelper = new OpenHelper(this.context); dh = new DBAdapter(this); db = openHelper.getWritableDatabase(); dh.SQL_INSERT_COUNTRY("AT", "Austria", "AUT"); } } i tried it with my country table because it has only 3 columns public class Country { private static String Iso2Count = "iso2_country"; private static String NameCount = "name_country"; private static String FlagCount = "flag_image_url_country"; public static final String TABLE_NAME = "country"; public static final String SQL_CREATE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + "(" + Iso2Count + " TEXT not NULL," + NameCount + " TEXT not NULL," + FlagCount + " TEXT not NULL," + "primary key(iso2_country)"; public boolean SQL_INSERT_COUNTRY(String Iso2CountIns, String NameCountIns, String FlagCountIns) { try{ db.execSQL("INSERT INTO " + "country" + "(" + Iso2Count + ", " + NameCount + ", " + FlagCount + ") " + "VALUES ( " + Iso2CountIns + ", " + NameCountIns +", " + FlagCountIns + " )"); return true; } catch (SQLException e) { return false; } } another question is it better to put the insert and select from each table into a separate class, so i have 1 class for each table or put them all into the DBAdapter class?

    Read the article

  • ?Oracle????SELECT????UNDO

    - by Liu Maclean(???)
    ????????Oracle?????(dirty read),?Oracle??????Asktom????????Oracle???????, ???undo??????????(before image)??????Consistent, ???????????????Oracle????????????? ????????? ??,??,Oracle?????????????RDBMS,???????????? ?????????2?????: _offline_rollback_segments or _corrupted_rollback_segments ?2?????????Oracle???????????ORA-600[4XXX]???????????????,???2??????Undo??Corruption????????????,?????2????????????????? ??????????????_offline_rollback_segments ? _corrupted_rollback_segments ?2?????: ???????(FORCE OPEN DATABASE) ????????????(consistent read & delayed block cleanout) ??????rollback segment??? ?????:???????Oracle????????,??????????2?????,?????????????!! _offline_rollback_segments ? _corrupted_rollback_segments ???????????: ??2???????Undo Segments(???/???)????????online ?UNDO$???????????OFFLINE??? ???instance??????????????????? ??????Undo Segments????????active transaction????????????dead??SMON???(????????SMON??(?):Recover Dead transaction) _OFFLINE_ROLLBACK_SEGMENTS(offline undo segment list)????(hidden parameter)?????: ???startup???open database???????_OFFLINE_ROLLBACK_SEGMENTS????Undo segments(???/???),?????undo segments????????alert.log???TRACE?????,???????startup?? ?????????????,?ITL?????undo segments?: ???undo segments?transaction table?????????????????? ???????????commit,?????CR??? ????undo segments????(???corrupted??,???missed??)???????????alert.log,??????? ?DML?????????????????????????????????CPU,????????????????????? _CORRUPTED_ROLLBACK_SEGMENTS(corrupted undo segment list)??????????: ?????startup?open database???_CORRUPTED_ROLLBACK_SEGMENTS????undo segments(???/???)???????? ???????_CORRUPTED_ROLLBACK_SEGMENTS???undo segments????????????commit,???undo segments???drop??? ??????????? ??????????????????,?????????????????? ??bootstrap???????????,?????????ORA-00704: bootstrap process failure??,???????????(???Oracle????:??ORA-00600:[4000] ORA-00704: bootstrap process failure????) ??????_CORRUPTED_ROLLBACK_SEGMENTS????????????????????,??????????????? Oracle???????TXChecker??????????? ???????2?????,??????????????_CORRUPTED_ROLLBACK_SEGMENTS?????SELECT????UNDO???????: SQL> alter system set event= '10513 trace name context forever, level 2' scope=spfile; System altered. SQL> alter system set "_in_memory_undo"=false scope=spfile; System altered. 10513 level 2 event????SMON ??rollback ??? dead transaction _in_memory_undo ?? in memory undo ?? SQL> startup force; ORACLE instance started. Total System Global Area 3140026368 bytes Fixed Size 2232472 bytes Variable Size 1795166056 bytes Database Buffers 1325400064 bytes Redo Buffers 17227776 bytes Database mounted. Database opened. session A: SQL> conn maclean/maclean Connected. SQL> create table maclean tablespace users as select 1 t1 from dual connect by level exec dbms_stats.gather_table_stats('','MACLEAN'); PL/SQL procedure successfully completed. SQL> set autotrace on; SQL> select sum(t1) from maclean; SUM(T1) ---------- 501 Execution Plan ---------------------------------------------------------- Plan hash value: 1679547536 ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 3 | | | | 2 | TABLE ACCESS FULL| MACLEAN | 501 | 1503 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------ Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 3 consistent gets 0 physical reads 0 redo size 515 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processe ???????????,????current block, ????????,consistent gets??3? SQL> update maclean set t1=0; 501 rows updated. SQL> alter system checkpoint; System altered. ??session A?commit; ???? session: SQL> conn maclean/maclean Connected. SQL> SQL> set autotrace on; SQL> select sum(t1) from maclean; SUM(T1) ---------- 501 Execution Plan ---------------------------------------------------------- Plan hash value: 1679547536 ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 3 | | | | 2 | TABLE ACCESS FULL| MACLEAN | 501 | 1503 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------ Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 505 consistent gets 0 physical reads 108 redo size 515 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed ?????? ?????????undo??CR?,???consistent gets??? 505 [oracle@vrh8 ~]$ ps -ef|grep LOCAL=YES |grep -v grep oracle 5841 5839 0 09:17 ? 00:00:00 oracleG10R25 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) [oracle@vrh8 ~]$ kill -9 5841 ??session A???Server Process????,???dead transaction ????smon?? select ktuxeusn, to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') "Time", ktuxesiz, ktuxesta from x$ktuxe where ktuxecfl = 'DEAD'; KTUXEUSN Time KTUXESIZ KTUXESTA ---------- -------------------- ---------- ---------------- 2 06-AUG-2012 09:20:45 7 ACTIVE ???1?active rollback segment SQL> conn maclean/maclean Connected. SQL> set autotrace on; SQL> select sum(t1) from maclean; SUM(T1) ---------- 501 Execution Plan ---------------------------------------------------------- Plan hash value: 1679547536 ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 3 | | | | 2 | TABLE ACCESS FULL| MACLEAN | 501 | 1503 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------ Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 411 consistent gets 0 physical reads 108 redo size 515 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed ????? ????kill?? ???smon ??dead transaction , ???????????? ?????undo??????? ????active?rollback segment??? SQL> select segment_name from dba_rollback_segs where segment_id=2; SEGMENT_NAME ------------------------------ _SYSSMU2$ SQL> alter system set "_corrupted_rollback_segments"='_SYSSMU2$' scope=spfile; System altered. ? _corrupted_rollback_segments ?? ???2?rollback segment, ????????undo SQL> startup force; ORACLE instance started. Total System Global Area 3140026368 bytes Fixed Size 2232472 bytes Variable Size 1795166056 bytes Database Buffers 1325400064 bytes Redo Buffers 17227776 bytes Database mounted. Database opened. SQL> conn maclean/maclean Connected. SQL> set autotrace on; SQL> select sum(t1) from maclean; SUM(T1) ---------- 94 Execution Plan ---------------------------------------------------------- Plan hash value: 1679547536 ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 3 | | | | 2 | TABLE ACCESS FULL| MACLEAN | 501 | 1503 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------ Statistics ---------------------------------------------------------- 228 recursive calls 0 db block gets 29 consistent gets 5 physical reads 116 redo size 514 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 4 sorts (memory) 0 sorts (disk) 1 rows processed SQL> / SUM(T1) ---------- 94 Execution Plan ---------------------------------------------------------- Plan hash value: 1679547536 ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 3 | | | | 2 | TABLE ACCESS FULL| MACLEAN | 501 | 1503 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------ Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 3 consistent gets 0 physical reads 0 redo size 514 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed ?????? consistent gets???3,?????????????????,??ITL???UNDO SEGMENTS?_corrupted_rollback_segments????,???????????COMMIT??,????UNDO? ???????,?????????????????????????(????????????????????),????????????????? ???? , ?????

    Read the article

  • C# select elements from IList

    - by user313884
    I have a list of objects: IList<O> O has several properties but only two of them are relevant: Date and Duration I want to "split" the list into several lists that contain only the objects that have matching Date and Duration Properties. Example: InitialList: 0- Date==1, Duration==7 1- Date==1, Duration==7 2- Date==2, Duration==7 3- Date==2, Duration==7 4- Date==2, Duration==14 5- Date==2, Duration==14 Desired result: IList<IList<O>: 0- 0- Date==1, Duration==7 1- Date==1, Duration==7 1- 0- Date==2, Duration==7 1- Date==2, Duration==7 2- 0- Date==2, Duration==14 1- Date==2, Duration==14 i know this can be done with some linq selects but am not sure how. thanks for the help.

    Read the article

  • C Socket Programming, problems with select() and fd_set

    - by wretrOvian
    Hello I'm learning my way about socket programming in C (referring to Beej). Here is a simple multi-user chat server i'm trying to implement: http://pastebin.com/gDzd0WqP On runtime, it gives Bus Error. It's coming from the lines 68-78. Help me trace the source of the problem? in fact, WHY is my code even REACHING that particular region? I've just run the server. no clients have connected.. :@ ps - i know my code is highly unreliable (no error checks anywhere), but i WILL do that at a later stage, i just want to TEST the functionality of the code before implementing it in all it's glory ;)

    Read the article

  • Slow select when inserting large amounts of data (MYSQL)

    - by siannopollo
    I have a process that imports a lot of data (950k rows) using inserts that insert 500 rows at a time. The process generally takes about 12 hours, which isn't too bad. Normally doing a query on the table is pretty quick (under 1 second) as I've put (what I think to be) the proper indexes in place. The problem I'm having is trying to run a query when the import process is running. It is making the query take almost 2 minutes! What can I do to make these two things not compete for resources (or whatever)? I've looked into "insert delayed" but not sure I want to change the table to MyISAM. Thanks for any help!

    Read the article

  • Rails date select options?

    - by Danny McClelland
    Hi Everyone, I have a date_select field in my rails application as follows: <%= f.date_select :dateinstructed %> I would like to re-order the drop down lists show they output as: DD/MM/YYYY According to what I have read you can use the :order option, but I am unsure how to actually use this option: <%= f.date_select :dateinstructed, :order = {:day, :month, :year} %> Obviously this isn't right, but what am I supposed to put in place of the: :day, :month, :year Any help would be appreciated! Thanks, Danny

    Read the article

  • How to Select Items in Dropdown in Selenium

    - by Marcus Gladir
    Firstly, I have been trying to get the dropdown from this web page: http://solutions.3m.com/wps/portal/3M/en_US/Interconnect/Home/Products/ProductCatalog/Catalog/?PC_Z7_RJH9U5230O73D0ISNF9B3C3SI1000000_nid=RFCNF5FK7WitWK7G49LP38glNZJXPCDXLDbl This is the code I have: import urllib2 from bs4 import BeautifulSoup import re from pprint import pprint import sys from selenium import common from selenium import webdriver import selenium.webdriver.support.ui as ui from boto.s3.key import Key import requests url = 'http://solutions.3m.com/wps/portal/3M/en_US/Interconnect/Home/Products/ProductCatalog/Catalog/?PC_Z7_RJH9U5230O73D0ISNF9B3C3SI1000000_nid=RFCNF5FK7WitWK7G49LP38glNZJXPCDXLDbl' element_xpath = '//*[@id="Component1"]' driver = webdriver.PhantomJS() driver.get(url) element = driver.find_element_by_xpath(element_xpath) element_xpath = '/option[@value="02"]' all_options = element.find_elements_by_tag_name("option") for option in all_options: print("Value is: %s" % option.get_attribute("value")) option.click() source = driver.page_source.encode('utf-8', 'ignore') driver.quit() source = str(source) soup = BeautifulSoup(source, 'html.parser') print soup What prints out is this: Traceback (most recent call last): File "../../../../test.py", line 58, in <module> Value is: XX main() File "../../../../test.py", line 46, in main option.click() File "/home/eric/dev/octocrawler-env/local/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/remote/webelement.py", line 54, in click self._execute(Command.CLICK_ELEMENT) File "/home/eric/dev/octocrawler-env/local/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/remote/webelement.py", line 228, in _execute return self._parent.execute(command, params) File "/home/eric/dev/octocrawler-env/local/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 165, in execute self.error_handler.check_response(response) File "/home/eric/dev/octocrawler-env/local/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 158, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotVisibleException: Message: u'{"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"81","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:51413","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\\"sessionId\\": \\"30e4fd50-f0e4-11e3-8685-6983e831d856\\", \\"id\\": \\":wdc:1402434863875\\"}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/30e4fd50-f0e4-11e3-8685-6983e831d856/element/%3Awdc%3A1402434863875/click"}}' ; Screenshot: available via screen And the weirdest most infuriating bit of it all is that sometimes it actually all works out. I have no clue what's going on here.

    Read the article

  • How to use the select tag in Struts2?

    - by Mes
    I have class A { private String field1; private String field2; private B b; } class B { private String field3; } List<A> myList; How can I access the field3 using the myList? This would work for field1 and field2, but how about field3? <s:iterator value="myList"> <tr> <td><s:property value="field1"/></td> <td><s:property value="field2"/></td> </tr> </s:iterator>

    Read the article

  • jquery select elements between two elements that are not siblings

    - by naugtur
    eg. [I've removed attributes, but it's a bit of auto-generated html] <img class="p"/> <div> hello world <p> <font><font size="2">text.<img class="p"/> some text</font></font> </p> <img class="p"/> <p> <font><font size="2">more text<img class="p"/> another piece of text </font></font> </p><img class="p"/> some text on the end </div> I need to apply some highlighting with backgrounds to all text that is between two closest [in the html code] img.p elements when hovering first of them. I have no idea how to do that. Lets say I hover the first img.p - it should highlight hello world and text. and nothing else. And now the worst part - I need the backgrounds to disappear on mouseleave. I need it to work with any HTML mess possible. The above is just an example and structure of the documents will differ. [tip. Processing the whole html before binding hover and putting some spans etc. is ok as long as it doesn't change the looks of the output document]

    Read the article

  • mysql select update

    - by Tillebeck
    Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID 1 1 1 2 1 3 2 4 2 5 2 6 Need Table a to have a comma separated list as given in table b. And then table b will become obsolete: Table a ID RelatedBs 1 1,2,3 2 4,5,6 This does not rund through all records, but just ad one 'b' to 'table a' UPDATE a, b SET relatedbs = CONCAT(relatedbs,',',b.id) WHERE a.id = b.aid

    Read the article

  • select SUM in Cake

    - by SpawnCxy
    When I tried using follow code to get the sum of the column named Serviceinfo.services $conditions = array('fields'=>array('SUM(Serviceinfo.services) as servicecount'),'conditions'=>array('time_id BETWEEN ? AND ?'=>array($startid,$endtid))); $services = $this->Serviceinfo->find('all',$conditions); I had to fetch the sum data with services[0][0]['servicecount'] which seems a little weird.And What I expect is services['Serviceinfo']['servicecount'],or more simple one.Then how can I fix this?Thanks in advance!

    Read the article

  • Not getting the right expected output for my Mysql Query?

    - by user1878107
    i've 4 tables as shown below doctors id name ------------ 1 Mathew 2 Praveen 3 Rosie 4 Arjun 5 Denis doctors_appointments id doctors_id patient_name contact date status -------------------------------------------------------------------------------------- 1 5 Nidhin 9876543210 2012-12-10 15:39:41 Registered 2 5 Sunny 9876543210 2012-12-18 15:39:48 Registered 3 5 Mani 9876543210 2012-12-12 15:39:57 Registered 4 2 John 9876543210 2012-12-24 15:40:09 Registered 5 4 Raj 9876543210 2012-12-05 15:41:57 Registered 6 3 Samuel 9876543210 2012-12-14 15:41:33 Registered 7 2 Louis 9876543210 2012-12-24 15:40:23 Registered 8 1 Federick 9876543210 2012-12-28 15:41:05 Registered 9 2 Sam 9876543210 2012-12-12 15:40:38 Registered 10 4 Sita 9876543210 2012-12-12 15:41:00 Registered doctors_dutyplan id doctor_id weeks time no_of_patients ------------------------------------------------------------------ 1 1 3,6,7 9:00am-1:00pm 10 2 2 3,4,5 1:00pm-4:00pm 7 3 3 3,6,7 10:00am-2:00pm 10 4 4 3,4,5,6 8:30am-12:30pm 12 5 5 3,4,5,6,7 9:00am-4:00pm 30 emp_leave id empid leavedate -------------------------------- 1 2 2012-12-05 14:42:36 2 2 2012-12-03 14:42:59 3 3 2012-12-03 14:43:06 4 3 2012-12-06 14:43:14 5 5 2012-12-04 14:43:24 My task is to find all the days in a month in which the doctor is available excluding the leave dates. My query what is wrote is given below: SELECT DATE_ADD( '2012-12-01', INTERVAL ROW DAY ) AS Date, ROW +1 AS DayOfMonth FROM ( SELECT @row := @row +1 AS ROW FROM ( SELECT 0 UNION ALL SELECT 1 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 )t1, ( SELECT 0 UNION ALL SELECT 1 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 )t2, ( SELECT @row := -1 )t3 LIMIT 31 )b WHERE DATE_ADD( '2012-12-01', INTERVAL ROW DAY ) BETWEEN '2012-12-01' AND '2012-12-31' AND DAYOFWEEK( DATE_ADD( '2012-12-01', INTERVAL ROW DAY ) ) =2 AND DATE_ADD( '2012-12-01', INTERVAL ROW DAY ) NOT IN ( SELECT DATE_FORMAT( l.leavedate, '%Y-%m-%d' ) AS date FROM doctors_dutyplan d LEFT JOIN emp_leave AS l ON d.doctor_id = l.empid WHERE doctor_id =2 ) This works fine for all doctors who took any leave in a particular day in a month (here in the example it is Decemeber 2012). and the result is shown below: Date DayOfMonth ----------------------- 2012-12-10 10 2012-12-17 17 2012-12-24 24 2012-12-31 31 But on the other hand for the doctors who did'nt took any leave , for that my query is showing empty table, example for the doctor Mathew whose id is 1, my query returns an empty result can anyone please tell a solution for this problem. Thanks in advance.

    Read the article

  • select rows with unidentical column values

    - by Bazon
    Hi Guys, I need to create a new data frame that excludes dams that appear in "dam1" and "dam2" columns on the same fosdate (fostering date). I tried df <- df[df$dam1!=dam2,] but did not work. Dam1 and dam2 are factors which are the ids's of mothers. my df: fosdate dam1 dam2 8/09/2009 2Z523 2Z523 30/10/2009 1W509 5C080 30/10/2009 1W509 5C640 30/10/2009 1W509 1W509 1/10/2009 1W311 63927 The new data frame that I need to get is: dfnew: fosdate dam1 dam2 30/10/2009 1W509 5C080 30/10/2009 1W509 5C640 1/10/2009 1W311 63927 Would appreciate any help! Bazon

    Read the article

  • MySQL Select statement Where table1.id != table2.id

    - by Michael
    I have a table of data which has posts, then I have a separate table of data which has deleted posts. What happens when a post is deleted is that it's ID get's added to the deleted table rather than removing the post entry. What is a clean efficient way of selecting all the posts from the posts table without selecting the ones that have their ID in the deleted table

    Read the article

  • jquery form select (if exists in $_POST)

    - by SoulieBaby
    Hi all, I'm trying to redo this in jQuery: <script language="JavaScript" type="text/javascript"> var thisIsSelected = '<?php echo $_POST['image']; ?>'; var sel1= document.getElementById('image'); sel1.value = thisIsSelected; </script> But I seem to keep breaking it lol Basically I want jQuery to check if $_POST['image'] exists and if so make it selected on the form. I'm assuming if it's possibly with javascript, jquery can do it easier ;)

    Read the article

  • PHP mySQL - select unique value that not being used from dirrefent table

    - by apis17
    Updates : Please see below i have table: data +-----------------------+--------------+-----------+ | State | d_country | d_postcode| +-----------------------+--------------+-----------+ | State1 | Country1 | 1111 | | State2 | Country2 | 2222 | | State3 | Country3 | 3333 | | State4 | Country4 | 4444 | +-----------------------+--------------+-----------+ And another table: user +-----------------------+--------------+-----------+ | Name | u_country | u_postcode| +-----------------------+--------------+-----------+ | Name1 | Country3 | 3333 | | Name2 | Country5 | 5555 | | Name3 | | 6666 | | Name4 | Country6 | 6666 | | Name5 | Country6 | 6666 | +-----------------------+--------------+-----------+ What SQL should i use to: Determine the number (count) of country that are not listed on table data. For example u_postcode is not listed in d_postcode is 5555 and 6666. It will return 2. List down name and what country not available in table data yet. Updates I want to use grouping to filter postcode and make Name3 and Name4 as different rows. For example: +-----------------------+--------------+-----------+ | Name | u_country | u_postcode| +-----------------------+--------------+-----------+ | Name2 | Country5 | 5555 | | Name3 | | 6666 | | Name4 | Country6 | 6666 | +-----------------------+--------------+-----------+ Any possible idea?

    Read the article

  • sql select puzzle: remove children when parent is filtered out

    - by knicnak32
    I have a table essentially: name has_children parent_id row_id values0.....valuesn parent 1 1 1 children 0 1 2 children 0 1 3 parent 0 4 4 parent 1 5 5 children 0 5 6 children 0 5 7 the values for the children can be different than the values for the parent. i want some selects/joins that will filter the table on a value column (i.e. 10) and will return the parent (even if false for the filter) if one of it's children is true for the filter. acceptable return: parent=true all children=false, return just parent parent=false >=1 children=true, return parent and one non-filtered child i'm sure this has been thought about before but i don't have the faintest idea how to phrase the question to find a solution.

    Read the article

  • select rows with unidentical column values using R

    - by Bazon
    Hi Guys, I need to create a new data frame that excludes dams that appear in "dam1" and "dam2" columns on the same fosdate (fostering date). I tried df <- df[df$dam1!=df$dam2,] but did not work. Dam1 and dam2 are factors which are the ids's of mothers. my df: fosdate dam1 dam2 8/09/2009 2Z523 2Z523 30/10/2009 1W509 5C080 30/10/2009 1W509 5C640 30/10/2009 1W509 1W509 1/10/2009 1W311 63927 The new data frame that I need to get is: dfnew: fosdate dam1 dam2 30/10/2009 1W509 5C080 30/10/2009 1W509 5C640 1/10/2009 1W311 63927 Would appreciate any help! Bazon

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >