额。如题。我是新手。。不怎么会用。。希望高手能给个简单的例子。比如。。我的数据库有username password
                      wc        123查询语句怎么写可以查到有无 wc 的这个用户啊

解决方案 »

  1.   

    Cursor cursor=db.query("表明",“列名”,“条件”,null,null,null.null);
      

  2.   

    Cursor cursor=db.query("表名",“列名”,“条件”,null,null,null.null); 
      

  3.   

    String where="PLAY_NAME="+username;
    Cursor cursor=getContentResolver().query(uri, null, where, null, null); 我是这样写的,,可是它还是报错啊晕
    01-01 12:38:41.086: ERROR/AndroidRuntime(1255): android.database.sqlite.SQLiteException: near "=": syntax error: , while compiling: SELECT * FROM PlAYER WHERE PLAY_NAME=
      

  4.   


    View.OnClickListener button1OnClickListener=new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    getIntent().setData(Uri.parse("content://com.huawei.biz.FormProvider/PlAYER/PLAY_NAME"));
            Uri uri=getIntent().getData();
            
    edit1=(EditText)findViewById(R.id.edit1);
    edit2=(EditText)findViewById(R.id.edit2);

    String username=edit1.getText().toString();
    String password=edit2.getText().toString();

    String where="PLAY_NAME="+username;
    Cursor cursor=getContentResolver().query(uri, null, where, null, null);
    if(username.equals("") || password.equals("")){
    Toast toast=Toast.makeText(getApplicationContext(), "用户名或密码不能为空", Toast.LENGTH_SHORT);
    toast.show(); }else if(!cursor.moveToNext()){
    Toast toast=Toast.makeText(getApplicationContext(), "没有"+username+"这个帐号", Toast.LENGTH_SHORT);
    toast.show();

    }else{

    jumping();
    }
    }

    };
    查询不了啊一直报那个错误。。求解
      

  5.   

    表user
    法一:
    Cursor cursor=db.query("user","username","username=?",new String[]{"wc"},null,null,null};
    if(cursor.getCount()>0)
       return true;
    法二:
    String sql="select username from user where username='wc'";
    Cursor cursor=db.rawQuery(sql);
    if(cursor.getCount()>0)
       return true;