标签: sqlite

我如何选择不出现在另一个表中的记录

表:电影

mID title                   year    director
101 Gone with the Wind  1939    Victor Fleming
102 Star Wars           1977    George Lucas
103 The Sound of Music  1965    Robert Wise
104 E.T.                    1982    Steven Spielberg
105 Titanic                 1997    James Cameron
106 Snow White          1937    <null>
107 Avatar                  2009    James Cameron
108 Raiders of the Lost Ark 1981    Steven Spielberg
Run Code Online (Sandbox Code Playgroud)

表:评级

rID mID stars   ratingDate
201 101 2   2011-01-22
201 101 4   2011-01-27
202 106 4   <null>
203 103 2   2011-01-20
203 108 4 …
Run Code Online (Sandbox Code Playgroud)

sql sqlite

0
推荐指数
1
解决办法
94
查看次数

在架构x86_64中找不到xcode c ++ sqlite3符号

嗨我想在xcode 4中的c ++项目中使用sqlite

现在我收到了这个错误

Ld/Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug/EMS normal x86_64 cd/Users/jayb/Documents/Developement/EMS/EMS setenv MACOSX_DEPLOYMENT_TARGET 10.8 /Applications/Xcode.app/目录/开发人员/工具链/ XcodeDefault.xctoolchain/usr/bin/clang ++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug -F/Users/jayb/Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Products/Debug -filelist/Users/jayb /Library/Developer/Xcode/DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg/Build/Intermediates/EMS.build/Debug/EMS.build/Objects-normal/x86_64/EMS.LinkFileList -mmacosx-version-min = 10.8 -o/Users/jayb /库/开发商/ Xcode中/ DerivedData/EMS-bpigynlzjbrescadebhoiupqmtkg /编译/产品/调试/ EMS

体系结构x86_64的未定义符号:"_ sqlite3_close",引用自:main.o"_sqlite3_errmsg"中的_main,引用自:main.o中的_main"_sqlite3_open",引自:main.o中的_main ld:未找到符号对于体系结构x86_64 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

我发现它可能是编译器选项-lsqlite3修复的链接器问题

但是,我如何在Xcode中添加该选项??????

我使用xcode 4.4上的"运行"按钮来编译我的项目.我没有在终端窗口编译.

这是我的代码

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <sqlite3.h>

using namespace std;

int main()
{   
    sqlite3 *db;
    int rc = sqlite3_open("EMSDB", &db);
    if (rc) {
        fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
        exit(0);
    }
    else {
        fprintf(stderr, "Opened Database successfully\n");
    }

    sqlite3_close(db); …
Run Code Online (Sandbox Code Playgroud)

c++ sqlite linker xcode4.4

0
推荐指数
2
解决办法
4082
查看次数

当外键已经存在时添加主键

我需要在“用户名”表上添加主键

我有3列:

userid int(10)
username char(20)
user char(50)
Run Code Online (Sandbox Code Playgroud)

和主键设置在“用户名”字段,我用它作为外键链接到另一个表。现在我还需要在'userid'字段上添加主键...所以我尝试了:

alter table `usernames` drop primary key, add primary key(userid,username);
Run Code Online (Sandbox Code Playgroud)

我得到一个错误的说法

ERROR 1553 (HY000): Cannot drop index 'PRIMARY":needed in a foreign key constraint 
Run Code Online (Sandbox Code Playgroud)

有什么可能的方法吗?

mysql sql sqlite mysql-workbench

0
推荐指数
1
解决办法
785
查看次数

如何在SQlite Android中自动减少主键值

我在android SQLite中有一个表,我试图弄清楚如何重置KEY_ID,我读到:DELETE FROM tablename应该删除所有内容并将自动增量字段重置为0但是当我这样做时它只是删除数据.插入新记录后,自动增量会在删除之前从中断处继续.我已经实现了一个longitemclicklistner列表,它获取了位置,我想从列表中删除特定项目.这是我的代码

public void deleteContact(Contact contact) {
        SQLiteDatabase db = this.getWritableDatabase();
        getWritableDatabase().delete(TABLE_CONTACTS, KEY_ID + " = ?",
                new String[] { String.valueOf(contact.getID()) } );


        db.close();
    }
Run Code Online (Sandbox Code Playgroud)

这是代码 onlongclicklistner

 public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                     int pos, long id) {
                // TODO Auto-generated method stub

                Log.v("long clicked","pos"+" "+pos);

                final int p=pos+1;

                final AlertDialog.Builder b = new AlertDialog.Builder(MainActivity.this);
                b.setIcon(android.R.drawable.ic_dialog_alert);
                b.setMessage("Are you sure you want to DELETE this Entry?");
                b.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface …
Run Code Online (Sandbox Code Playgroud)

sqlite android sqliteopenhelper android-sqlite

0
推荐指数
1
解决办法
1422
查看次数

编译时出现sqlite3错误

我使用Xcode5在ios7上编码,编译器给我这个错误.

隐式转换失去整数精度sqlite3_int64又名long longint.

下面的代码如下:

if([self chatId] != nil) {
    [chatId release];
}
chatId = [[NSNumber alloc] initWithInt:sqlite3_last_insert_rowid(database)];
sqlite3_finalize(sqlStatement);
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

sqlite objective-c

0
推荐指数
1
解决办法
1015
查看次数

Android需要在onCreate方法中使用什么

我在我的主要活动类中有这个代码

public class HomeScreenActivity extends Activity {

    private Button contactButton;
    private Button groupContactButton;
    private Button historyButton;
    private Button optionsButton;
    private ListView contactsView;

    public static int selectedContactIndex = -1;

    DatabaseHandler db = new DatabaseHandler(getApplicationContext());
    List<Contact> contactList = db.getAllContacts();
    ArrayAdapter<Contact> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_screen);

        contactButton = (Button) findViewById(R.id.contactButton);
        contactButton.setSelected(true);
        groupContactButton = (Button) findViewById(R.id.groupContactButton);
        historyButton = (Button) findViewById(R.id.historyButton);
        optionsButton = (Button) findViewById(R.id.optionsButton);
        contactsView = (ListView) findViewById(R.id.contactsView);

        // Set up contact adaptor so the contact list can be viewed …
Run Code Online (Sandbox Code Playgroud)

sqlite android

0
推荐指数
1
解决办法
198
查看次数

来自SQLite的Android格式日期

我以支持的格式(yyyy-mm-dd)在sqlite数据库中插入日期.现在我希望用户在查询时根据国家/地区显示日期格式(意大利dd-mm-yyyy,美国yyyy-mm-dd等...)

我如何能?谢谢

sqlite android date view

0
推荐指数
1
解决办法
8117
查看次数

SQLite:表X没有名为Y的列

我在这里已经阅读了很多关于上述问题的线索/问题,但似乎没有任何解决方案对我有用.这是我的数据库创建:

  public static final String TABLE_CARDS = "cards";
  public static final String COLUMN_ID = "_id";
  public static final String COLUMN_QUESTION = "question";
  public static final String COLUMN_ANSWER = "answer";

  private static final String DATABASE_NAME = "cards.db";
  private static final int DATABASE_VERSION = 1;

  // Database creation sql statement
  private static final String DATABASE_CREATE = "create table "
      + TABLE_CARDS + "(" 
      + COLUMN_ID + " integer primary key autoincrement, " 
      + COLUMN_QUESTION + " text not null, " 
      + COLUMN_ANSWER …
Run Code Online (Sandbox Code Playgroud)

sqlite android

0
推荐指数
1
解决办法
7381
查看次数

将上下文传递给Android中的dbHelper的非活动类

我试图从非活动类加载SQLite数据库

我需要DBHelperAdapter类的上下文并使用ApplicationContextProvider如下所述的类.(我没有将这个添加到清单中,因为一些教程建议但是因为我不确定如何.)

CNYearsAdapter myCNYearsAdapter = new CNYearsAdapter( ApplicationContextProvider.getContext());
Run Code Online (Sandbox Code Playgroud)

应用环境提供者:

package com.example.kuachart;

import android.app.Application;
import android.content.Context;


public class ApplicationContextProvider extends Application {

/**
 * Keeps a reference of the application context
 */
private static Context sContext;

@Override
public void onCreate() {
    super.onCreate();

    sContext = getApplicationContext();

}

/**
 * Returns the application context
 *
 * @return application context
 */
public static Context getContext() {
    return sContext;
}

}
Run Code Online (Sandbox Code Playgroud)

目前,实例化上面的行myCNYearsAdapter崩溃了程序,因此我不确定Application上下文提供程序是否正常工作.是否有另一种方法可以将上下文传递给此非活动类?

sqlite android android-context

0
推荐指数
1
解决办法
5612
查看次数

SQLiteException:插入数据库时​​出错:语法错误(代码1)

我相信错误在于我设置DATABASE_CREATE的方式.我在这里错过了什么吗?我得到SQLiteException,其中long id = -1.如果我提供足够的细节,请告诉我.我试过设置KEY_ID ="_ id";

E/SQLiteLog(2385): (1) near "group": syntax error
E/SQLiteDatabase(2385): Error inserting group=demo
E/SQLiteDatabase(2385): android.database.sqlite.SQLiteException: near "group": syntax error (code 1): , while compiling: INSERT INTO groups(group) VALUES (?)
LOG(2385): Inserting record...
LOG(2385): mGroupName = demo
LOG(2385): long id = -1
Run Code Online (Sandbox Code Playgroud)

DBAdapter.java

public static final String KEY_ID = "id";
public static final String KEY_GROUP_NAME = "group";
public static final String TAG = "DBAdapter";
public static final String DATABASE_NAME = "GroupsDB";
public static final String DATABASE_TABLE = "groups"; …
Run Code Online (Sandbox Code Playgroud)

sql sqlite android sqliteopenhelper android-sqlite

0
推荐指数
1
解决办法
2119
查看次数